--- a/mail/test/browser/moz.build
+++ b/mail/test/browser/moz.build
@@ -38,34 +38,16 @@ BROWSER_CHROME_MANIFESTS += [
'tabmail/browser.ini',
'utils/browser.ini',
]
DIRS += [
'shared-modules',
]
-TESTING_JS_MODULES.mozmill += [
- '../resources/mozmill/mozmill/extension/content/modules/controller.jsm',
- '../resources/mozmill/mozmill/extension/content/modules/elementslib.jsm',
- '../resources/mozmill/mozmill/extension/content/modules/events.jsm',
- '../resources/mozmill/mozmill/extension/content/modules/frame.jsm',
- '../resources/mozmill/mozmill/extension/content/modules/init.jsm',
- '../resources/mozmill/mozmill/extension/content/modules/jum.jsm',
- '../resources/mozmill/mozmill/extension/content/modules/mozmill.jsm',
- '../resources/mozmill/mozmill/extension/content/modules/utils.jsm',
- '../resources/mozmill/mozmill/extension/content/stdlib/arrays.jsm',
- '../resources/mozmill/mozmill/extension/content/stdlib/dom.jsm',
- '../resources/mozmill/mozmill/extension/content/stdlib/EventUtils.jsm',
- '../resources/mozmill/mozmill/extension/content/stdlib/httpd.jsm',
- '../resources/mozmill/mozmill/extension/content/stdlib/os.jsm',
- '../resources/mozmill/mozmill/extension/content/stdlib/securable-module.jsm',
- '../resources/mozmill/mozmill/extension/content/stdlib/strings.jsm',
-]
-
TEST_HARNESS_FILES.testing.mochitest.fakeserver += [
'../../../mailnews/test/fakeserver/auth.js',
'../../../mailnews/test/fakeserver/imapd.js',
'../../../mailnews/test/fakeserver/maild.js',
'../../../mailnews/test/fakeserver/nntpd.js',
'../../../mailnews/test/fakeserver/pop3d.js',
'../../../mailnews/test/fakeserver/smtpd.js',
]
rename from mail/test/resources/mozmill/mozmill/extension/content/stdlib/EventUtils.jsm
rename to mail/test/browser/shared-modules/EventUtils.jsm
rename from mail/test/resources/mozmill/mozmill/extension/content/stdlib/arrays.jsm
rename to mail/test/browser/shared-modules/arrays.jsm
rename from mail/test/resources/mozmill/mozmill/extension/content/modules/controller.jsm
rename to mail/test/browser/shared-modules/controller.jsm
rename from mail/test/resources/mozmill/mozmill/extension/content/stdlib/dom.jsm
rename to mail/test/browser/shared-modules/dom.jsm
rename from mail/test/resources/mozmill/mozmill/extension/content/modules/elementslib.jsm
rename to mail/test/browser/shared-modules/elementslib.jsm
rename from mail/test/resources/mozmill/mozmill/extension/content/modules/events.jsm
rename to mail/test/browser/shared-modules/events.jsm
rename from mail/test/resources/mozmill/mozmill/extension/content/modules/frame.jsm
rename to mail/test/browser/shared-modules/frame.jsm
rename from mail/test/resources/mozmill/mozmill/extension/content/stdlib/httpd.jsm
rename to mail/test/browser/shared-modules/httpd.jsm
rename from mail/test/resources/mozmill/mozmill/extension/content/modules/init.jsm
rename to mail/test/browser/shared-modules/init.jsm
rename from mail/test/resources/mozmill/mozmill/extension/content/modules/jum.jsm
rename to mail/test/browser/shared-modules/jum.jsm
--- a/mail/test/browser/shared-modules/moz.build
+++ b/mail/test/browser/shared-modules/moz.build
@@ -1,30 +1,45 @@
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
TESTING_JS_MODULES.mozmill += [
'AccountManagerHelpers.jsm',
'AddressBookHelpers.jsm',
+ 'arrays.jsm',
'AttachmentHelpers.jsm',
'CloudfileHelpers.jsm',
'ComposeHelpers.jsm',
'ContentTabHelpers.jsm',
+ 'controller.jsm',
'CustomizationHelpers.jsm',
+ 'dom.jsm',
'DOMHelpers.jsm',
+ 'elementslib.jsm',
+ 'events.jsm',
+ 'EventUtils.jsm',
'FolderDisplayHelpers.jsm',
+ 'frame.jsm',
+ 'httpd.jsm',
+ 'init.jsm',
+ 'jum.jsm',
'JunkHelpers.jsm',
'KeyboardHelpers.jsm',
'MessageHelpers.jsm',
'MockObjectHelpers.jsm',
'MouseEventHelpers.jsm',
+ 'mozmill.jsm',
'NewMailAccountHelpers.jsm',
'NNTPHelpers.jsm',
'NotificationBoxHelpers.jsm',
+ 'os.jsm',
'PrefTabHelpers.jsm',
'PromptHelpers.jsm',
'QuickFilterBarHelpers.jsm',
'SearchWindowHelpers.jsm',
+ 'securable-module.jsm',
+ 'strings.jsm',
'SubscribeWindowHelpers.jsm',
+ 'utils.jsm',
'WindowHelpers.jsm',
]
rename from mail/test/resources/mozmill/mozmill/extension/content/modules/mozmill.jsm
rename to mail/test/browser/shared-modules/mozmill.jsm
rename from mail/test/resources/mozmill/mozmill/extension/content/stdlib/os.jsm
rename to mail/test/browser/shared-modules/os.jsm
rename from mail/test/resources/mozmill/mozmill/extension/content/stdlib/securable-module.jsm
rename to mail/test/browser/shared-modules/securable-module.jsm
rename from mail/test/resources/mozmill/mozmill/extension/content/stdlib/strings.jsm
rename to mail/test/browser/shared-modules/strings.jsm
rename from mail/test/resources/mozmill/mozmill/extension/content/modules/utils.jsm
rename to mail/test/browser/shared-modules/utils.jsm
deleted file mode 100644
--- a/mail/test/mozmill/.eslintrc.js
+++ /dev/null
@@ -1,13 +0,0 @@
-"use strict";
-
-module.exports = {
- globals: {
- __file__: true,
- collector: true,
- elementslib: true,
- mozmill: true,
- },
- rules: {
- "func-names": "off",
- },
-};
deleted file mode 100644
--- a/mail/test/mozmill/Makefile.in
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-include $(moztopsrcdir)/config/rules.mk
-
-# We're installing to _tests/mozmill
-_DEST_DIR = $(DEPTH)/_tests/mozmill
-
-$(_DEST_DIR):
- $(NSINSTALL) -D $@
-
-
-# Copy MozMill and its dependencies over, and set up a virtualenv. The
-# virtualenv directory is outside because we don't want to bundle it up during
-# stage-package.
-VIRTUALENV_DIR = $(topobjdir)/_virtualenvs/init
-mozmill-virtualenv: $(_DEST_DIR)
- unset MACOSX_DEPLOYMENT_TARGET && \
- $(PYTHON) $(_DEST_DIR)/resources/installmozmill.py $(VIRTUALENV_DIR)
-
-ifndef MOZ_AUTOMATION
-# We don't run mozmill tests as part of the build in automation, so skip
-# creating a virtualenv for them.
-libs:: mozmill-virtualenv
-endif
-
-PKG_STAGE = $(DIST)/test-stage
-
-stage-package:
- $(NSINSTALL) -D $(PKG_STAGE)/mozmill/
- $(NSINSTALL) -D $(PKG_STAGE)/mozmill/fakeserver
- $(NSINSTALL) -D $(PKG_STAGE)/mozmill/resources
- @(cd $(commtopsrcdir)/mail/test/mozmill && tar $(TAR_CREATE_FLAGS) - *) | (cd $(PKG_STAGE)/mozmill/ && tar -xf -)
- @(cd $(DEPTH)/_tests/mozmill/fakeserver && tar $(TAR_CREATE_FLAGS) - *) | (cd $(PKG_STAGE)/mozmill/fakeserver && tar -xf -)
- @(cd $(DEPTH)/_tests/mozmill/resources && tar $(TAR_CREATE_FLAGS) - *) | (cd $(PKG_STAGE)/mozmill/resources && tar -xf -)
deleted file mode 100644
--- a/mail/test/mozmill/account/test-ab-whitelist.js
+++ /dev/null
@@ -1,162 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-var mozmill = ChromeUtils.import(
- "chrome://mozmill/content/modules/mozmill.jsm"
-);
-var controller = ChromeUtils.import(
- "chrome://mozmill/content/modules/controller.jsm"
-);
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-
-var {
- click_account_tree_row,
- get_account_tree_row,
- open_advanced_settings,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/AccountManagerHelpers.jsm"
-);
-var {
- assert_equals,
- assert_false,
- assert_true,
- FAKE_SERVER_HOSTNAME,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var gOldWhiteList = null;
-var gKeyString = null;
-
-var gAccount = null;
-
-function setupModule(module) {
- let server = MailServices.accounts.FindServer(
- "tinderbox",
- FAKE_SERVER_HOSTNAME,
- "pop3"
- );
- gAccount = MailServices.accounts.FindAccountForServer(server);
- let serverKey = server.key;
-
- gKeyString = "mail.server." + serverKey + ".whiteListAbURI";
- gOldWhiteList = Services.prefs.getCharPref(gKeyString);
- Services.prefs.setCharPref(gKeyString, "");
-}
-
-function teardownModule(module) {
- Services.prefs.setCharPref(gKeyString, gOldWhiteList);
-}
-
-/* First, test that when we initially load the account manager, that
- * we're not whitelisting any address books. Then, we'll check all
- * address books and save.
- */
-function subtest_check_whitelist_init_and_save(amc) {
- // Ok, the advanced settings window is open. Let's choose
- // the junkmail settings.
- let accountRow = get_account_tree_row(gAccount.key, "am-junk.xhtml", amc);
- click_account_tree_row(amc, accountRow);
-
- let doc = amc.window.document.getElementById("contentFrame").contentDocument;
-
- // At this point, we shouldn't have anything checked, but we should have
- // the two default address books (Personal and Collected) displayed
- let list = doc.getElementById("whiteListAbURI");
- assert_equals(
- 2,
- list.getRowCount(),
- "There was an unexpected number of address books"
- );
-
- // Now we'll check both address books
- for (let i = 0; i < list.getRowCount(); i++) {
- let abNode = list.getItemAtIndex(i);
- amc.click(new elib.Elem(abNode.firstElementChild));
- }
-
- // And close the dialog
- amc.window.document.getElementById("accountManager").acceptDialog();
-}
-
-/* Next, we'll make sure that the address books we checked in
- * subtest_check_whitelist_init_and_save were properly saved.
- * Then, we'll clear the address books and save.
- */
-function subtest_check_whitelist_load_and_clear(amc) {
- let accountRow = get_account_tree_row(gAccount.key, "am-junk.xhtml", amc);
- click_account_tree_row(amc, accountRow);
-
- let doc = amc.window.document.getElementById("contentFrame").contentDocument;
- let list = doc.getElementById("whiteListAbURI");
- let whiteListURIs = Services.prefs.getCharPref(gKeyString).split(" ");
-
- for (let i = 0; i < list.getRowCount(); i++) {
- let abNode = list.getItemAtIndex(i);
- assert_equals(
- "true",
- abNode.firstElementChild.getAttribute("checked"),
- "Should have been checked"
- );
- // Also ensure that the address book URI was properly saved in the
- // prefs
- assert_true(whiteListURIs.includes(abNode.getAttribute("value")));
- // Now un-check that address book
- amc.click(new elib.Elem(abNode.firstElementChild));
- }
-
- // And close the dialog
- amc.window.document.getElementById("accountManager").acceptDialog();
-}
-
-/* Finally, we'll make sure that the address books we cleared
- * were actually cleared.
- */
-function subtest_check_whitelist_load_cleared(amc) {
- let accountRow = get_account_tree_row(gAccount.key, "am-junk.xhtml", amc);
- click_account_tree_row(amc, accountRow);
-
- let doc = amc.window.document.getElementById("contentFrame").contentDocument;
- let list = doc.getElementById("whiteListAbURI");
- let whiteListURIs = "";
-
- try {
- whiteListURIs = Services.prefs.getCharPref(gKeyString);
- // We should have failed here, because the pref should have been cleared
- // out.
- throw Error(
- "The whitelist preference for this server wasn't properly cleared."
- );
- } catch (e) {}
-
- for (let i = 0; i < list.getRowCount(); i++) {
- let abNode = list.getItemAtIndex(i);
- assert_equals(
- "false",
- abNode.firstElementChild.getAttribute("checked"),
- "Should not have been checked"
- );
- // Also ensure that the address book URI was properly cleared in the
- // prefs
- assert_false(whiteListURIs.includes(abNode.getAttribute("value")));
- }
-
- // And close the dialog
- amc.window.document.getElementById("accountManager").acceptDialog();
-}
-
-function test_address_book_whitelist() {
- open_advanced_settings(subtest_check_whitelist_init_and_save);
- open_advanced_settings(subtest_check_whitelist_load_and_clear);
- open_advanced_settings(subtest_check_whitelist_load_cleared);
-}
deleted file mode 100644
--- a/mail/test/mozmill/account/test-account-actions.js
+++ /dev/null
@@ -1,196 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-var {
- click_account_tree_row,
- get_account_tree_row,
- open_advanced_settings,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/AccountManagerHelpers.jsm"
-);
-var {
- assert_equals,
- assert_not_equals,
- assert_true,
- close_popup,
- wait_for_popup_to_open,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var imapAccount, nntpAccount, originalAccountCount;
-
-function setupModule(module) {
- // There may be pre-existing accounts from other tests.
- originalAccountCount = MailServices.accounts.allServers.length;
- // There already should be a Local Folders account created.
- // It is needed for this test.
- assert_true(MailServices.accounts.localFoldersServer);
-
- // Create an IMAP server
- let imapServer = MailServices.accounts
- .createIncomingServer("nobody", "example.com", "imap")
- .QueryInterface(Ci.nsIImapIncomingServer);
-
- let identity = MailServices.accounts.createIdentity();
- identity.email = "tinderbox@example.com";
-
- imapAccount = MailServices.accounts.createAccount();
- imapAccount.incomingServer = imapServer;
- imapAccount.addIdentity(identity);
-
- // Create a NNTP server
- let nntpServer = MailServices.accounts
- .createIncomingServer(null, "example.nntp.invalid", "nntp")
- .QueryInterface(Ci.nsINntpIncomingServer);
-
- identity = MailServices.accounts.createIdentity();
- identity.email = "tinderbox2@example.com";
-
- nntpAccount = MailServices.accounts.createAccount();
- nntpAccount.incomingServer = nntpServer;
- nntpAccount.addIdentity(identity);
- // Now there should be 2 more accounts.
- assert_equals(
- MailServices.accounts.allServers.length,
- originalAccountCount + 2
- );
-}
-
-function teardownModule(module) {
- // Remove our test accounts to leave the profile clean.
- MailServices.accounts.removeAccount(nntpAccount);
- MailServices.accounts.removeAccount(imapAccount);
- // There should be only the original accounts left.
- assert_equals(MailServices.accounts.allServers.length, originalAccountCount);
-}
-
-/**
- * Check that the account actions for the account are enabled or disabled appropriately.
- *
- * @param amc the account options controller
- * @param aAccountKey the key of the account to select
- * @param aIsSetAsDefaultEnabled true if the menuitem should be enabled, false otherwise
- * @param aIsRemoveEnabled true if the menuitem should be enabled, false otherwise
- * @param aIsAddAccountEnabled true if the menuitems (Add Mail Account+Add Other Account)
- * should be enabled, false otherwise
- */
-function subtest_check_account_actions(
- amc,
- aAccountKey,
- aIsSetAsDefaultEnabled,
- aIsRemoveEnabled,
- aIsAddAccountEnabled
-) {
- let accountRow = get_account_tree_row(aAccountKey, null, amc);
- click_account_tree_row(amc, accountRow);
-
- // click the Actions Button to bring up the popup with menuitems to test
- amc.click(amc.eid("accountActionsButton"), 5, 5);
- wait_for_popup_to_open(amc.e("accountActionsDropdown"));
-
- let actionAddMailAccount = amc.e("accountActionsAddMailAccount");
- assert_not_equals(actionAddMailAccount, undefined);
- assert_equals(
- !actionAddMailAccount.getAttribute("disabled"),
- aIsAddAccountEnabled
- );
-
- let actionAddOtherAccount = amc.e("accountActionsAddOtherAccount");
- assert_not_equals(actionAddOtherAccount, undefined);
- assert_equals(
- !actionAddOtherAccount.getAttribute("disabled"),
- aIsAddAccountEnabled
- );
-
- let actionSetDefault = amc.e("accountActionsDropdownSetDefault");
- assert_not_equals(actionSetDefault, undefined);
- assert_equals(
- !actionSetDefault.getAttribute("disabled"),
- aIsSetAsDefaultEnabled
- );
-
- let actionRemove = amc.e("accountActionsDropdownRemove");
- assert_not_equals(actionRemove, undefined);
- assert_equals(!actionRemove.getAttribute("disabled"), aIsRemoveEnabled);
-
- close_popup(amc, amc.eid("accountActionsDropdown"));
-}
-
-function test_account_actions() {
- // IMAP account: can be default, can be removed.
- open_advanced_settings(function(amc) {
- subtest_check_account_actions(amc, imapAccount.key, true, true, true);
- });
-
- // NNTP (News) account: can't be default, can be removed.
- open_advanced_settings(function(amc) {
- subtest_check_account_actions(amc, nntpAccount.key, false, true, true);
- });
-
- // Local Folders account: can't be removed, can't be default.
- var localFoldersAccount = MailServices.accounts.FindAccountForServer(
- MailServices.accounts.localFoldersServer
- );
- open_advanced_settings(function(amc) {
- subtest_check_account_actions(
- amc,
- localFoldersAccount.key,
- false,
- false,
- true
- );
- });
- // SMTP server row: can't be removed, can't be default.
- open_advanced_settings(function(amc) {
- subtest_check_account_actions(amc, null, false, false, true);
- });
-
- // on the IMAP account, disable Delete Account menu item
- let disableItemPref = "mail.disable_button.delete_account";
-
- // Set the pref on the default branch, otherwise .getBoolPref on it throws.
- Services.prefs.getDefaultBranch("").setBoolPref(disableItemPref, true);
- Services.prefs.lockPref(disableItemPref);
-
- open_advanced_settings(function(amc) {
- subtest_check_account_actions(amc, imapAccount.key, true, false, true);
- });
-
- Services.prefs.unlockPref(disableItemPref);
- Services.prefs.getDefaultBranch("").deleteBranch(disableItemPref);
-
- // on the IMAP account, disable Set as Default menu item
- disableItemPref = "mail.disable_button.set_default_account";
-
- Services.prefs.getDefaultBranch("").setBoolPref(disableItemPref, true);
- Services.prefs.lockPref(disableItemPref);
-
- open_advanced_settings(function(amc) {
- subtest_check_account_actions(amc, imapAccount.key, false, true, true);
- });
-
- Services.prefs.unlockPref(disableItemPref);
- Services.prefs.getDefaultBranch("").deleteBranch(disableItemPref);
-
- // on the IMAP account, disable Add new Account menu items
- disableItemPref = "mail.disable_new_account_addition";
-
- Services.prefs.getDefaultBranch("").setBoolPref(disableItemPref, true);
- Services.prefs.lockPref(disableItemPref);
-
- open_advanced_settings(function(amc) {
- subtest_check_account_actions(amc, imapAccount.key, true, true, false);
- });
-
- Services.prefs.unlockPref(disableItemPref);
- Services.prefs.getDefaultBranch("").deleteBranch(disableItemPref);
-}
deleted file mode 100644
--- a/mail/test/mozmill/account/test-account-deletion.js
+++ /dev/null
@@ -1,111 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * This test checks proper deletion of an account from the Account manager.
- */
-
-"use strict";
-
-var { open_advanced_settings, remove_account } = ChromeUtils.import(
- "resource://testing-common/mozmill/AccountManagerHelpers.jsm"
-);
-var { assert_equals, assert_false, assert_true } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-var gPopAccount, gImapAccount, gOriginalAccountCount;
-
-function setupModule(module) {
- // There may be pre-existing accounts from other tests.
- gOriginalAccountCount = MailServices.accounts.allServers.length;
-
- // Create a POP server
- let popServer = MailServices.accounts
- .createIncomingServer("nobody", "pop.foo.invalid", "pop3")
- .QueryInterface(Ci.nsIPop3IncomingServer);
-
- let identity = MailServices.accounts.createIdentity();
- identity.email = "tinderbox@pop.foo.invalid";
-
- gPopAccount = MailServices.accounts.createAccount();
- gPopAccount.incomingServer = popServer;
- gPopAccount.addIdentity(identity);
-
- // Create an IMAP server
- let imapServer = MailServices.accounts
- .createIncomingServer("nobody", "imap.foo.invalid", "imap")
- .QueryInterface(Ci.nsIImapIncomingServer);
-
- identity = MailServices.accounts.createIdentity();
- identity.email = "tinderbox@imap.foo.invalid";
-
- gImapAccount = MailServices.accounts.createAccount();
- gImapAccount.incomingServer = imapServer;
- gImapAccount.addIdentity(identity);
-
- assert_equals(
- MailServices.accounts.allServers.length,
- gOriginalAccountCount + 2
- );
-}
-
-function teardownModule(module) {
- // There should be only the original accounts left.
- assert_equals(MailServices.accounts.allServers.length, gOriginalAccountCount);
-}
-
-function test_account_data_deletion() {
- open_advanced_settings(function(amc) {
- subtest_account_data_deletion1(amc);
- });
-
- open_advanced_settings(function(amc) {
- subtest_account_data_deletion2(amc);
- });
-}
-
-/**
- * Bug 274452
- * Check if files of an account are preserved.
- *
- * @param amc The account options controller.
- */
-function subtest_account_data_deletion1(amc) {
- let accountDir = gPopAccount.incomingServer.localPath;
- assert_true(accountDir.isDirectory());
-
- // Get some existing file in the POP3 account data dir.
- let inboxFile = accountDir.clone();
- inboxFile.append("Inbox.msf");
- assert_true(inboxFile.isFile());
-
- remove_account(gPopAccount, amc, true, false);
- gPopAccount = null;
- assert_true(accountDir.exists());
-}
-
-/**
- * Bug 274452
- * Check if files of an account can be deleted.
- *
- * @param amc The account options controller.
- */
-function subtest_account_data_deletion2(amc) {
- let accountDir = gImapAccount.incomingServer.localPath;
- assert_true(accountDir.isDirectory());
-
- // Get some file in the IMAP account data dir.
- let inboxFile = accountDir.clone();
- inboxFile.append("INBOX.msf");
- assert_true(inboxFile.isFile());
-
- remove_account(gImapAccount, amc, true, true);
- gImapAccount = null;
- assert_false(accountDir.exists());
-}
deleted file mode 100644
--- a/mail/test/mozmill/account/test-account-port-setting.js
+++ /dev/null
@@ -1,92 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-
-var {
- click_account_tree_row,
- get_account_tree_row,
- open_advanced_settings,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/AccountManagerHelpers.jsm"
-);
-var { FAKE_SERVER_HOSTNAME, mc } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { input_value, delete_all_existing } = ChromeUtils.import(
- "resource://testing-common/mozmill/KeyboardHelpers.jsm"
-);
-
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-var PORT_NUMBERS_TO_TEST = [
- "110", // The original port number. We don't input this though.
- "456", // Random port number.
- "995", // The SSL port number.
- "110", // Back to the original.
-];
-
-var gTestNumber;
-
-function subtest_check_set_port_number(amc, aDontSet) {
- // This test expects the following POP account to exist by default
- // with port number 110 and no security.
- let server = MailServices.accounts.FindServer(
- "tinderbox",
- FAKE_SERVER_HOSTNAME,
- "pop3"
- );
- let account = MailServices.accounts.FindAccountForServer(server);
-
- let accountRow = get_account_tree_row(account.key, "am-server.xhtml", amc);
- click_account_tree_row(amc, accountRow);
-
- let iframe = amc.window.document.getElementById("contentFrame");
- let portElem = iframe.contentDocument.getElementById("server.port");
- portElem.focus();
-
- if (portElem.value != PORT_NUMBERS_TO_TEST[gTestNumber - 1]) {
- throw new Error(
- "Port Value is not " +
- PORT_NUMBERS_TO_TEST[gTestNumber - 1] +
- " as expected, it is: " +
- portElem.value
- );
- }
-
- if (!aDontSet) {
- delete_all_existing(amc, new elib.Elem(portElem));
- input_value(amc, PORT_NUMBERS_TO_TEST[gTestNumber]);
-
- mc.sleep(0);
- }
-
- mc.click(
- new elib.Elem(
- amc.window.document.getElementById("accountManager").getButton("accept")
- )
- );
-}
-
-function subtest_check_port_number(amc) {
- subtest_check_set_port_number(amc, true);
-}
-
-function test_account_port_setting() {
- for (
- gTestNumber = 1;
- gTestNumber < PORT_NUMBERS_TO_TEST.length;
- ++gTestNumber
- ) {
- open_advanced_settings(subtest_check_set_port_number);
- }
-
- open_advanced_settings(subtest_check_port_number);
-}
deleted file mode 100644
--- a/mail/test/mozmill/account/test-account-settings-infrastructure.js
+++ /dev/null
@@ -1,461 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * This test checks proper operation of the account settings panes infrastructure
- * in the Account manager. E.g. if the values of elements are properly stored when
- * panes are switched.
- *
- * New checks can be added to it as needed.
- */
-
-"use strict";
-
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-
-var {
- click_account_tree_row,
- get_account_tree_row,
- open_advanced_settings,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/AccountManagerHelpers.jsm"
-);
-var {
- assert_equals,
- assert_false,
- assert_true,
- FAKE_SERVER_HOSTNAME,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var gPopAccount, gImapAccount, gOriginalAccountCount;
-
-function setupModule(module) {
- // There may be pre-existing accounts from other tests.
- gOriginalAccountCount = MailServices.accounts.allServers.length;
-
- // Create a POP server
- let popServer = MailServices.accounts
- .createIncomingServer("nobody", "pop.invalid", "pop3")
- .QueryInterface(Ci.nsIPop3IncomingServer);
-
- let identity = MailServices.accounts.createIdentity();
- identity.email = "tinderbox@pop.invalid";
-
- gPopAccount = MailServices.accounts.createAccount();
- gPopAccount.incomingServer = popServer;
- gPopAccount.addIdentity(identity);
-
- // Create an IMAP server
- let imapServer = MailServices.accounts
- .createIncomingServer("nobody", "imap.invalid", "imap")
- .QueryInterface(Ci.nsIImapIncomingServer);
-
- identity = MailServices.accounts.createIdentity();
- identity.email = "tinderbox@imap.invalid";
-
- gImapAccount = MailServices.accounts.createAccount();
- gImapAccount.incomingServer = imapServer;
- gImapAccount.addIdentity(identity);
-
- // Now there should be one more account.
- assert_equals(
- MailServices.accounts.allServers.length,
- gOriginalAccountCount + 2
- );
-}
-
-function teardownModule(module) {
- // Remove our test accounts to leave the profile clean.
- MailServices.accounts.removeAccount(gPopAccount);
- MailServices.accounts.removeAccount(gImapAccount);
-
- // There should be only the original accounts left.
- assert_equals(MailServices.accounts.allServers.length, gOriginalAccountCount);
-}
-
-/**
- * Bug 525024.
- * Check that the options in the server pane are properly preserved across
- * pane switches.
- */
-function test_account_dot_IDs() {
- open_advanced_settings(function(amc) {
- subtest_check_account_dot_IDs(amc);
- });
-}
-
-/**
- * Check that the options in the server pane are stored even if the id
- * of the element contains multiple dots (not used in standard TB yet
- * but extensions may want it).
- *
- * @param amc the account options controller
- */
-function subtest_check_account_dot_IDs(amc) {
- let accountRow = get_account_tree_row(
- gPopAccount.key,
- "am-server.xhtml",
- amc
- );
- click_account_tree_row(amc, accountRow);
-
- let iframe = amc.e("contentFrame").contentDocument;
- // Check whether a standard element with "server.loginAtStartUp" stores its
- // value properly.
- let loginCheck = iframe.getElementById("server.loginAtStartUp");
- assert_false(loginCheck.checked);
- amc.check(new elib.Elem(loginCheck), true);
-
- accountRow = get_account_tree_row(gPopAccount.key, "am-junk.xhtml", amc);
- click_account_tree_row(amc, accountRow);
-
- accountRow = get_account_tree_row(gPopAccount.key, "am-server.xhtml", amc);
- click_account_tree_row(amc, accountRow);
-
- // Re-assign iframe.contentDocument because it was lost when changing panes
- // (uses loadURI to load a new document).
- iframe = amc.e("contentFrame").contentDocument;
-
- // Check by element properties.
- loginCheck = iframe.getElementById("server.loginAtStartUp");
- assert_true(loginCheck.checked);
-
- // Check for correct value in the accountValues array, that will be saved into prefs.
- let rawCheckValue = amc.window.getAccountValue(
- gPopAccount,
- amc.window.getValueArrayFor(gPopAccount),
- "server",
- "loginAtStartUp",
- null,
- false
- );
-
- assert_true(rawCheckValue);
-
- // The "server.login.At.StartUp" value does not exist yet, so the value should be 'null'.
- rawCheckValue = amc.window.getAccountValue(
- gPopAccount,
- amc.window.getValueArrayFor(gPopAccount),
- "server",
- "login.At.StartUp",
- null,
- false
- );
- assert_equals(rawCheckValue, null);
-
- // Change the ID so that "server.login.At.StartUp" exists now.
- loginCheck.id = "server.login.At.StartUp";
-
- accountRow = get_account_tree_row(gPopAccount.key, "am-junk.xhtml", amc);
- click_account_tree_row(amc, accountRow);
-
- accountRow = get_account_tree_row(gPopAccount.key, "am-server.xhtml", amc);
- click_account_tree_row(amc, accountRow);
-
- // Check for correct value in the accountValues array, that will be saved into prefs.
- // We can't check by element property here, because the am-server.xhtml pane was
- // reloaded and the element now has the original ID of "server.loginAtStartUp".
- rawCheckValue = amc.window.getAccountValue(
- gPopAccount,
- amc.window.getValueArrayFor(gPopAccount),
- "server",
- "login.At.StartUp",
- null,
- false
- );
-
- assert_true(rawCheckValue);
-}
-
-/**
- * Test for bug 807101.
- * Check if form controls are properly disabled when their attached prefs are locked.
- */
-function test_account_locked_prefs() {
- open_advanced_settings(function(amc) {
- subtest_check_locked_prefs_addressing(amc);
- });
-
- open_advanced_settings(function(amc) {
- subtest_check_locked_prefs_server(amc);
- });
-}
-
-/**
- * Check that the LDAP server selection elements (radio group) are properly
- * disabled when their attached pref (prefstring attribute) is locked.
- *
- * @param amc the account options controller
- */
-function subtest_check_locked_prefs_addressing(amc) {
- let accountRow = get_account_tree_row(
- gPopAccount.key,
- "am-addressing.xhtml",
- amc
- );
- click_account_tree_row(amc, accountRow);
-
- let iframe = amc.e("contentFrame").contentDocument;
-
- // By default, 'use global LDAP server preferences' is set, not the
- // 'different LDAP server'.
- let useLDAPdirectory = iframe.getElementById("directories");
- assert_false(useLDAPdirectory.selected);
-
- // So the server selector is disabled.
- let LDAPdirectory = iframe.getElementById("identity.directoryServer");
- assert_true(LDAPdirectory.disabled);
-
- // And the Edit button too.
- let LDAPeditButton = iframe.getElementById("editButton");
- assert_true(LDAPeditButton.disabled);
-
- // Now toggle the 'different LDAP server' on. The server selector
- // and edit button should enable.
- amc.radio(new elib.Elem(useLDAPdirectory));
- assert_false(LDAPdirectory.disabled);
- assert_false(LDAPeditButton.disabled);
-
- // Lock the pref for the server selector.
- let prefstring = LDAPdirectory.getAttribute("prefstring");
- let controlPref = prefstring.replace(
- "%identitykey%",
- gPopAccount.defaultIdentity.key
- );
- Services.prefs.getDefaultBranch("").setBoolPref(controlPref, "xxx");
- Services.prefs.lockPref(controlPref);
-
- // Refresh the pane by switching to another one.
- accountRow = get_account_tree_row(gPopAccount.key, "am-junk.xhtml", amc);
- click_account_tree_row(amc, accountRow);
-
- accountRow = get_account_tree_row(
- gPopAccount.key,
- "am-addressing.xhtml",
- amc
- );
- click_account_tree_row(amc, accountRow);
-
- // Re-assign iframe.contentDocument because it was lost when changing panes
- // (uses loadURI to load a new document).
- iframe = amc.e("contentFrame").contentDocument;
-
- // We are now back and the 'different LDAP server' should still be selected
- // (the setting was saved).
- useLDAPdirectory = iframe.getElementById("directories");
- assert_true(useLDAPdirectory.selected);
-
- // But now the server selector should be disabled due to locked pref.
- LDAPdirectory = iframe.getElementById("identity.directoryServer");
- assert_true(LDAPdirectory.disabled);
-
- // The edit button still enabled (does not depend on the same pref lock)
- LDAPeditButton = iframe.getElementById("editButton");
- assert_false(LDAPeditButton.disabled);
-
- // Unlock the pref to clean up.
- Services.prefs.unlockPref(controlPref);
- Services.prefs.getDefaultBranch("").deleteBranch(controlPref);
-}
-
-/**
- * Check that the POP3 'keep on server' settings elements (2-level
- * checkboxes + textbox) are properly disabled when their attached pref
- * (prefstring attribute) is locked.
- *
- * @param amc the account options controller
- */
-function subtest_check_locked_prefs_server(amc) {
- let accountRow = get_account_tree_row(
- gPopAccount.key,
- "am-server.xhtml",
- amc
- );
- click_account_tree_row(amc, accountRow);
-
- let iframe = amc.e("contentFrame").contentDocument;
-
- // Top level leaveOnServer checkbox, disabled by default.
- let leaveOnServer = iframe.getElementById("pop3.leaveMessagesOnServer");
- assert_false(leaveOnServer.disabled);
- assert_false(leaveOnServer.checked);
-
- // Second level deleteByAge checkbox, disabled by default.
- let deleteByAge = iframe.getElementById("pop3.deleteByAgeFromServer");
- assert_true(deleteByAge.disabled);
- assert_false(deleteByAge.checked);
-
- // Third level daysToLeave textbox, disabled by default.
- let daysToLeave = iframe.getElementById("pop3.numDaysToLeaveOnServer");
- assert_true(daysToLeave.disabled);
-
- // When leaveOnServer is checked, only deleteByAge will get enabled.
- amc.check(new elib.Elem(leaveOnServer), true);
- assert_true(leaveOnServer.checked);
- assert_false(deleteByAge.disabled);
- assert_true(daysToLeave.disabled);
-
- // When deleteByAge is checked, daysToLeave will get enabled.
- amc.check(new elib.Elem(deleteByAge), true);
- assert_true(deleteByAge.checked);
- assert_false(daysToLeave.disabled);
-
- // Lock the pref deleteByAge checkbox (middle of the element hierarchy).
- let prefstring = deleteByAge.getAttribute("prefstring");
- let controlPref = prefstring.replace(
- "%serverkey%",
- gPopAccount.incomingServer.key
- );
- Services.prefs.getDefaultBranch("").setBoolPref(controlPref, true);
- Services.prefs.lockPref(controlPref);
-
- // Refresh the pane by switching to another one.
- accountRow = get_account_tree_row(gPopAccount.key, "am-junk.xhtml", amc);
- click_account_tree_row(amc, accountRow);
-
- accountRow = get_account_tree_row(gPopAccount.key, "am-server.xhtml", amc);
- click_account_tree_row(amc, accountRow);
-
- // Re-assign iframe.contentDocument because it was lost when changing panes
- // (uses loadURI to load a new document).
- iframe = amc.e("contentFrame").contentDocument;
-
- // Now leaveOnServer was preserved as checked.
- leaveOnServer = iframe.getElementById("pop3.leaveMessagesOnServer");
- assert_false(leaveOnServer.disabled);
- assert_true(leaveOnServer.checked);
-
- // Now deleteByAge was preserved as checked but is locked/disabled.
- deleteByAge = iframe.getElementById("pop3.deleteByAgeFromServer");
- assert_true(deleteByAge.disabled);
- assert_true(deleteByAge.checked);
-
- // Because deleteByAge is checked, daysToLeave should be enabled.
- daysToLeave = iframe.getElementById("pop3.numDaysToLeaveOnServer");
- assert_false(daysToLeave.disabled);
-
- // When leaveOnserver is unchecked, both of deleteByAge and daysToLeave
- // should get disabled.
- amc.check(new elib.Elem(leaveOnServer), false);
- assert_false(leaveOnServer.disabled);
- assert_false(leaveOnServer.checked);
-
- assert_true(deleteByAge.disabled);
- assert_true(deleteByAge.checked);
- assert_true(daysToLeave.disabled);
-
- // Unlock the pref to clean up.
- Services.prefs.unlockPref(controlPref);
- Services.prefs.getDefaultBranch("").deleteBranch(controlPref);
-}
-
-/**
- * Bug 530142.
- * Check that that if one field is set to a value, switching directly to another
- * account pane showing the same field really loads the value from the new account,
- * even when empty. This is tested on the Reply-To field.
- */
-function test_replyTo_leak() {
- open_advanced_settings(function(amc) {
- subtest_check_replyTo_leak(amc);
- });
-}
-
-/**
- * @param amc the account options controller
- */
-function subtest_check_replyTo_leak(amc) {
- let accountRow = get_account_tree_row(gPopAccount.key, null, amc);
- click_account_tree_row(amc, accountRow);
-
- let iframe = amc.window.document.getElementById("contentFrame");
-
- // The Reply-To field should be empty.
- let replyAddress = iframe.contentDocument.getElementById("identity.replyTo");
- assert_equals(replyAddress.value, "");
-
- // Now we set a value into it and switch to another account, the main pane.
- replyAddress.value = "somewhere@else.com";
-
- // This test expects the following POP account to exist by default
- // in the test profile with port number 110 and no security.
- let firstServer = MailServices.accounts.FindServer(
- "tinderbox",
- FAKE_SERVER_HOSTNAME,
- "pop3"
- );
- let firstAccount = MailServices.accounts.FindAccountForServer(firstServer);
-
- accountRow = get_account_tree_row(firstAccount.key, null, amc);
- click_account_tree_row(amc, accountRow);
-
- // the Reply-To field should be empty as this account does not have it set.
- replyAddress = iframe.contentDocument.getElementById("identity.replyTo");
- assert_equals(replyAddress.value, "");
-}
-
-/**
- * Test for bug 804091.
- * Check if onchange handlers are properly executed when panes are switched.
- */
-function test_account_onchange_handler() {
- open_advanced_settings(function(amc) {
- subtest_check_onchange_handler(amc);
- });
-}
-
-/**
- * Check if onchange handlers are properly executed when panes are switched.
- *
- * @param amc the account options controller
- */
-function subtest_check_onchange_handler(amc) {
- let accountRow = get_account_tree_row(
- gImapAccount.key,
- "am-offline.xhtml",
- amc
- );
- click_account_tree_row(amc, accountRow);
-
- let iframe = amc.e("contentFrame").contentDocument;
-
- let autoSync = iframe.getElementById("autosyncValue");
- // 30 is the default value so check if we are in clean state.
- assert_equals(autoSync.value, 30);
-
- let autoSyncInterval = iframe.getElementById("autosyncInterval");
- // 1 is the default value and means the 30 is in days.
- assert_equals(autoSyncInterval.value, 1);
-
- // Now type in 35 (days).
- amc.radio(new elib.ID(iframe, "useAutosync.ByAge"));
- autoSync.select();
- amc.type(new elib.Elem(autoSync), "35");
-
- // Immediately switch to another pane and back.
- accountRow = get_account_tree_row(gImapAccount.key, "am-junk.xhtml", amc);
- click_account_tree_row(amc, accountRow);
-
- accountRow = get_account_tree_row(gImapAccount.key, "am-offline.xhtml", amc);
- click_account_tree_row(amc, accountRow);
-
- iframe = amc.e("contentFrame").contentDocument;
-
- // The pane optimized the entered value a bit. So now we should find 5.
- autoSync = iframe.getElementById("autosyncValue");
- assert_equals(autoSync.value, 5);
-
- // And the unit is 7 days = week.
- autoSyncInterval = iframe.getElementById("autosyncInterval");
- assert_equals(autoSyncInterval.value, 7);
-}
deleted file mode 100644
--- a/mail/test/mozmill/account/test-account-tree.js
+++ /dev/null
@@ -1,202 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * This test checks proper operation of the account tree in the Account manager.
- */
-
-"use strict";
-
-var {
- click_account_tree_row,
- get_account_tree_row,
- open_advanced_settings,
- remove_account,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/AccountManagerHelpers.jsm"
-);
-var { assert_equals, assert_false, assert_true } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-var gPopAccount, gOriginalAccountCount;
-
-function setupModule(module) {
- // There may be pre-existing accounts from other tests.
- gOriginalAccountCount = MailServices.accounts.allServers.length;
-
- // Create a POP server
- let popServer = MailServices.accounts
- .createIncomingServer("nobody", "foo.invalid", "pop3")
- .QueryInterface(Ci.nsIPop3IncomingServer);
-
- let identity = MailServices.accounts.createIdentity();
- identity.email = "tinderbox@foo.invalid";
-
- gPopAccount = MailServices.accounts.createAccount();
- gPopAccount.incomingServer = popServer;
- gPopAccount.addIdentity(identity);
-
- // Now there should be one more account.
- assert_equals(
- MailServices.accounts.allServers.length,
- gOriginalAccountCount + 1
- );
-}
-
-function teardownModule(module) {
- if (gPopAccount) {
- // Remove our test account to leave the profile clean.
- MailServices.accounts.removeAccount(gPopAccount);
- gPopAccount = null;
- }
- // There should be only the original accounts left.
- assert_equals(MailServices.accounts.allServers.length, gOriginalAccountCount);
-}
-
-/**
- * Test for bug 536248.
- * Check if the account manager dialog remembers the open state of accounts.
- */
-function test_account_open_state() {
- open_advanced_settings(function(amc) {
- subtest_check_account_open_state(amc, true);
- });
- open_advanced_settings(function(amc) {
- subtest_check_account_open_state(amc, false);
- });
- // After this test all the accounts must be "open".
-}
-
-/**
- * Check if the open state of accounts is in the wished state.
- *
- * @param amc The account options controller.
- * @param aWishedState The open state in which the account row should be found (bool).
- */
-function subtest_check_account_open_state(amc, aWishedState) {
- let accountRow = get_account_tree_row(gPopAccount.key, null, amc);
- click_account_tree_row(amc, accountRow);
-
- // See if the account row is in the wished open state.
- let accountTree = amc.e("accounttree");
- assert_equals(accountRow, accountTree.view.selection.currentIndex);
- assert_equals(accountTree.view.isContainerOpen(accountRow), aWishedState);
-
- accountTree.view.toggleOpenState(accountRow);
- assert_equals(accountTree.view.isContainerOpen(accountRow), !aWishedState);
-
- // Whatever the open state of the account was, selecting one of its subpanes
- // must open it.
- amc.window.selectServer(gPopAccount.incomingServer, "am-junk.xhtml");
- assert_true(accountTree.view.isContainerOpen(accountRow));
-
- // Set the proper state again for continuation of the test.
- accountTree.view
- .getItemAtIndex(accountRow)
- .setAttribute("open", !aWishedState);
- assert_equals(accountTree.view.isContainerOpen(accountRow), !aWishedState);
-}
-
-/**
- * Bug 740617.
- * Check if the default account is styled in bold.
- *
- */
-function test_default_account_highlight() {
- open_advanced_settings(function(amc) {
- subtest_check_default_account_highlight(amc);
- });
-}
-
-/**
- * Check if the default account is styled in bold and another account is not.
- *
- * @param amc The account options controller.
- */
-function subtest_check_default_account_highlight(amc) {
- // Select the default account.
- let accountRow = get_account_tree_row(
- MailServices.accounts.defaultAccount.key,
- null,
- amc
- );
- click_account_tree_row(amc, accountRow);
-
- let accountTree = amc.e("accounttree");
- assert_equals(accountRow, accountTree.view.selection.currentIndex);
- let cell = accountTree.view.getItemAtIndex(accountRow).firstElementChild
- .firstElementChild;
- assert_equals(cell.tagName, "treecell");
-
- // We can't read the computed style of the tree cell directly, so at least see
- // if the isDefaultServer-true property is set on it. Hopefully the proper style
- // is attached to this property.
- let propArray = accountTree.view
- .getCellProperties(accountRow, accountTree.columns.getColumnAt(0))
- .split(" ");
- assert_true(propArray.includes("isDefaultServer-true"));
-
- // Now select another account that is not default.
- accountRow = get_account_tree_row(gPopAccount.key, null, amc);
- click_account_tree_row(amc, accountRow);
-
- // There should isDefaultServer-true on its tree cell.
- propArray = accountTree.view
- .getCellProperties(accountRow, accountTree.columns.getColumnAt(0))
- .split(" ");
- assert_false(propArray.includes("isDefaultServer-true"));
-}
-/**
- * Bug 58713.
- * Check if after deleting an account the next one is selected.
- *
- * This test should always be the last one as it removes our specially
- * created gPopAccount.
- */
-function test_selection_after_account_deletion() {
- open_advanced_settings(function(amc) {
- subtest_check_selection_after_account_deletion(amc);
- });
-}
-
-/**
- * Check if after deleting an account the next one is selected.
- *
- * @param amc The account options controller.
- */
-function subtest_check_selection_after_account_deletion(amc) {
- let accountList = [];
- let accountTreeNode = amc.e("account-tree-children");
- // Build the list of accounts in the account tree (order is important).
- for (let i = 0; i < accountTreeNode.children.length; i++) {
- if ("_account" in accountTreeNode.children[i]) {
- let curAccount = accountTreeNode.children[i]._account;
- if (!accountList.includes(curAccount)) {
- accountList.push(curAccount);
- }
- }
- }
-
- // Get position of the current account in the account list.
- let accountIndex = accountList.indexOf(gPopAccount);
-
- // Remove our account.
- remove_account(gPopAccount, amc);
- gPopAccount = null;
- // Now there should be only the original accounts left.
- assert_equals(MailServices.accounts.allServers.length, gOriginalAccountCount);
-
- // See if the currently selected account is the one next in the account list.
- let accountTree = amc.e("accounttree");
- let accountRow = accountTree.view.selection.currentIndex;
- assert_equals(
- accountTree.view.getItemAtIndex(accountRow)._account,
- accountList[accountIndex + 1]
- );
-}
deleted file mode 100644
--- a/mail/test/mozmill/account/test-account-values.js
+++ /dev/null
@@ -1,402 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * This test checks proper operation of the account settings panes
- * when certain special or invalid values are entered into the fields.
- */
-
-"use strict";
-
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-
-var {
- click_account_tree_row,
- get_account_tree_row,
- open_advanced_settings,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/AccountManagerHelpers.jsm"
-);
-var { assert_equals, assert_false } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { input_value, delete_all_existing } = ChromeUtils.import(
- "resource://testing-common/mozmill/KeyboardHelpers.jsm"
-);
-var { plan_for_modal_dialog, wait_for_modal_dialog } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var gPopAccount, gOriginalAccountCount;
-
-function setupModule(module) {
- // There may be pre-existing accounts from other tests.
- gOriginalAccountCount = MailServices.accounts.allServers.length;
-
- // Create a POP server
- let popServer = MailServices.accounts
- .createIncomingServer("nobody", "example.invalid", "pop3")
- .QueryInterface(Ci.nsIPop3IncomingServer);
-
- let identity = MailServices.accounts.createIdentity();
- identity.email = "tinderbox@example.invalid";
-
- gPopAccount = MailServices.accounts.createAccount();
- gPopAccount.incomingServer = popServer;
- gPopAccount.addIdentity(identity);
-
- // Now there should be one more account.
- assert_equals(
- MailServices.accounts.allServers.length,
- gOriginalAccountCount + 1
- );
-}
-
-function teardownModule(module) {
- // Remove our test account to leave the profile clean.
- MailServices.accounts.removeAccount(gPopAccount);
- // There should be only the original accounts left.
- assert_equals(MailServices.accounts.allServers.length, gOriginalAccountCount);
-}
-
-/**
- * Bug 208628.
- * Check that if the CC field is empty, enabling CC will automatically
- * prefill the currently default email address.
- */
-function test_default_CC_address() {
- open_advanced_settings(function(amc) {
- subtest_check_default_CC_address(amc);
- });
-}
-
-/**
- * Check that if the CC field is empty, enabling CC will automatically
- * prefill the currently default email address.
- *
- * @param amc the account options controller
- */
-function subtest_check_default_CC_address(amc) {
- let accountRow = get_account_tree_row(
- gPopAccount.key,
- "am-copies.xhtml",
- amc
- );
- click_account_tree_row(amc, accountRow);
-
- let iframe = amc.window.document.getElementById("contentFrame");
-
- let defaultAddress = iframe.contentDocument.getElementById("identity.email")
- .value;
- let ccCheck = iframe.contentDocument.getElementById("identity.doCc");
- let ccAddress = iframe.contentDocument.getElementById("identity.doCcList");
- // The CC checkbox is not enabled and the address value is empty.
- assert_false(ccCheck.checked);
- assert_equals(ccAddress.value, "");
- // After ticking the CC checkbox the default address should be prefilled.
- amc.check(new elib.Elem(ccCheck), true);
- assert_equals(ccAddress.value, defaultAddress);
-
- let bccCheck = iframe.contentDocument.getElementById("identity.doBcc");
- let bccAddress = iframe.contentDocument.getElementById("identity.doBccList");
- // The BCC checkbox is not enabled but we set the address value to something.
- assert_false(bccCheck.checked);
- assert_equals(bccAddress.value, "");
- let bccUserAddress = "somebody@else.invalid";
- bccAddress.value = bccUserAddress;
- // After ticking the BCC checkbox the current value of the address should not change.
- amc.check(new elib.Elem(bccCheck), true);
- assert_equals(bccAddress.value, bccUserAddress);
-}
-
-/**
- * Bug 720199.
- * Check if the account name automatically changes when the user changes
- * the username or hostname.
- */
-function test_account_name() {
- // We already have a POP account ready.
- // Create also a NNTP server.
- let nntpServer = MailServices.accounts
- .createIncomingServer(null, "example.nntp.invalid", "nntp")
- .QueryInterface(Ci.nsINntpIncomingServer);
-
- let identity = MailServices.accounts.createIdentity();
- identity.email = "tinderbox2@example.invalid";
-
- let nntpAccount = MailServices.accounts.createAccount();
- nntpAccount.incomingServer = nntpServer;
- nntpAccount.addIdentity(identity);
-
- assert_equals(
- gPopAccount.incomingServer.prettyName,
- "nobody on example.invalid"
- );
- assert_equals(nntpAccount.incomingServer.prettyName, "example.nntp.invalid");
-
- // The automatic account name update works only if the name is
- // in the form of user@host.
- gPopAccount.incomingServer.prettyName = "nobody@example.invalid";
-
- let newHost = "some.host.invalid";
- let newUser = "somebody";
-
- // On NNTP there is no user name so just set new hostname.
- open_advanced_settings(function(amc) {
- subtest_check_account_name(nntpAccount, newHost, null, amc);
- });
-
- // And see if the account name is updated to it.
- assert_equals(nntpAccount.incomingServer.prettyName, newHost);
-
- // On POP3 there is both user name and host name.
- // Set new host name first.
- open_advanced_settings(function(amc) {
- subtest_check_account_name(gPopAccount, newHost, null, amc);
- });
-
- // And see if in the account name the host part is updated to it.
- assert_equals(gPopAccount.incomingServer.prettyName, "nobody@" + newHost);
-
- // Set new host name first.
- open_advanced_settings(function(amc) {
- subtest_check_account_name(gPopAccount, null, newUser, amc);
- });
-
- // And see if in the account name the user part is updated.
- assert_equals(gPopAccount.incomingServer.prettyName, newUser + "@" + newHost);
-
- newHost = "another.host.invalid";
- newUser = "anotherbody";
-
- // Set user name and host name at once.
- open_advanced_settings(function(amc) {
- subtest_check_account_name(gPopAccount, newHost, newUser, amc);
- });
-
- // And see if in the account name the host part is updated to it.
- assert_equals(gPopAccount.incomingServer.prettyName, newUser + "@" + newHost);
-
- // Now have an account name where the name does not match the hostname.
- gPopAccount.incomingServer.prettyName = newUser + "@example.invalid";
-
- newHost = "third.host.invalid";
- // Set the host name again.
- open_advanced_settings(function(amc) {
- subtest_check_account_name(gPopAccount, newHost, null, amc);
- });
-
- // And the account name should not be touched.
- assert_equals(
- gPopAccount.incomingServer.prettyName,
- newUser + "@example.invalid"
- );
-
- MailServices.accounts.removeAccount(nntpAccount);
-}
-
-/**
- * Changes the user name and hostname to the supplied values.
- *
- * @param aAccount the account to change
- * @param aNewHostname the hostname value to set
- * @param aNewUsername the username value to set
- * @param amc the account options controller
- */
-function subtest_check_account_name(aAccount, aNewHostname, aNewUsername, amc) {
- let accountRow = get_account_tree_row(aAccount.key, "am-server.xhtml", amc);
- click_account_tree_row(amc, accountRow);
-
- let iframe = amc.window.document.getElementById("contentFrame");
-
- if (aNewHostname) {
- let hostname = iframe.contentDocument.getElementById("server.realHostName");
- assert_equals(hostname.value, aAccount.incomingServer.realHostName);
-
- // Now change the server host name.
- hostname.value = aNewHostname;
- }
-
- if (aNewUsername) {
- let username = iframe.contentDocument.getElementById("server.realUsername");
- assert_equals(username.value, aAccount.incomingServer.realUsername);
-
- // Now change the server user name.
- username.value = aNewUsername;
- }
-
- if (aNewUsername) {
- // If username has changed, we get a confirmation dialog.
- plan_for_modal_dialog("commonDialogWindow", function(cdc) {
- // Just dismiss it.
- cdc.window.document.documentElement
- .querySelector("dialog")
- .acceptDialog();
- });
- }
- // We really need to save the new values so click OK on the Account settings.
- amc.window.document.documentElement.querySelector("dialog").acceptDialog();
- if (aNewUsername) {
- wait_for_modal_dialog("commonDialogWindow");
- }
-}
-
-/**
- * Bug 536768.
- * Check if invalid junk target settings (folders) are fixed to sane values.
- */
-function test_invalid_junk_target() {
- // Set the junk target prefs to invalid values.
- let branch = Services.prefs.getBranch(
- "mail.server." + gPopAccount.incomingServer.key + "."
- );
- branch.setCharPref("spamActionTargetAccount", "some random non-existent URI");
- branch.setCharPref("spamActionTargetFolder", "some random non-existent URI");
- let moveOnSpam = true;
- branch.setBoolPref("moveOnSpam", moveOnSpam);
- open_advanced_settings(function(amc) {
- subtest_check_invalid_junk_target(amc);
- });
-
- // The pref has no default so its non-existence means it was cleared.
- moveOnSpam = branch.getBoolPref("moveOnSpam", false);
- assert_false(moveOnSpam);
- // The targets should point to the same pop account now.
- let targetAccount = branch.getCharPref("spamActionTargetAccount");
- assert_equals(targetAccount, gPopAccount.incomingServer.serverURI);
- let targetFolder = branch.getCharPref("spamActionTargetFolder");
- assert_equals(targetFolder, gPopAccount.incomingServer.serverURI + "/Junk");
-}
-
-/**
- * Just show the Junk settings pane and let it fix the values.
- *
- * @param amc the account options controller
- */
-function subtest_check_invalid_junk_target(amc) {
- let accountRow = get_account_tree_row(gPopAccount.key, "am-junk.xhtml", amc);
- click_account_tree_row(amc, accountRow);
-
- // We need to save the new fixed values so click OK on the Account settings.
- amc.window.document.documentElement.querySelector("dialog").acceptDialog();
-}
-
-/**
- * Bug 327812.
- * Checks if invalid server hostnames are not accepted.
- */
-function test_invalid_hostname() {
- let branch = Services.prefs.getBranch(
- "mail.server." + gPopAccount.incomingServer.key + "."
- );
- let origHostname = branch.getCharPref("realhostname");
-
- open_advanced_settings(function(amc) {
- subtest_check_invalid_hostname(amc, false, origHostname);
- });
- open_advanced_settings(function(amc) {
- subtest_check_invalid_hostname(amc, true, origHostname);
- });
-
- // The new bad hostname should not have been saved.
- let newHostname = branch.getCharPref("realhostname");
- assert_equals(origHostname, newHostname);
-}
-
-/**
- * Set the hostname to an invalid value and check if it gets fixed.
- *
- * @param amc the account options controller
- * @param aExitSettings Attempt to close the Account settings dialog.
- * @param aOriginalHostname Original hostname of this server.
- */
-function subtest_check_invalid_hostname(amc, aExitSettings, aOriginalHostname) {
- let accountRow = get_account_tree_row(
- gPopAccount.key,
- "am-server.xhtml",
- amc
- );
- click_account_tree_row(amc, accountRow);
-
- let iframe = amc.window.document.getElementById("contentFrame");
- let hostname = iframe.contentDocument.getElementById("server.realHostName");
- assert_equals(hostname.value, aOriginalHostname);
-
- hostname.value = "some_invalid+host&domain*in>invalid";
-
- if (!aExitSettings) {
- accountRow = get_account_tree_row(gPopAccount.key, "am-junk.xhtml", amc);
- click_account_tree_row(amc, accountRow);
-
- // The invalid hostname should be set back to previous value at this point...
- accountRow = get_account_tree_row(gPopAccount.key, "am-server.xhtml", amc);
- click_account_tree_row(amc, accountRow);
-
- // ...let's check that:
- iframe = amc.window.document.getElementById("contentFrame");
- hostname = iframe.contentDocument.getElementById("server.realHostName");
- assert_equals(hostname.value, aOriginalHostname);
- } else {
- // If the hostname is bad, we should get a warning dialog.
- plan_for_modal_dialog("commonDialogWindow", function(cdc) {
- // Just dismiss it.
- cdc.window.document.documentElement
- .querySelector("dialog")
- .acceptDialog();
- });
-
- // Click OK on the Account settings.
- amc.window.document.documentElement.querySelector("dialog").acceptDialog();
-
- wait_for_modal_dialog("commonDialogWindow");
- }
-}
-
-/**
- * Bug 1426328.
- * Check that the AM will trim user added spaces around text values.
- */
-const badName = "trailing space ";
-const badEmail = " leading_space@example.com";
-
-function test_trailing_spaces() {
- open_advanced_settings(function(amc) {
- subtest_check_trailing_spaces(amc);
- });
- assert_equals(gPopAccount.incomingServer.prettyName, badName.trim());
- assert_equals(gPopAccount.defaultIdentity.email, badEmail.trim());
-}
-
-/**
- * Check that the AM will trim user added spaces around text values
- * when storing them into the account.
- *
- * @param amc the account options controller
- */
-function subtest_check_trailing_spaces(amc) {
- let accountRow = get_account_tree_row(gPopAccount.key, null, amc);
- click_account_tree_row(amc, accountRow);
-
- let iframe = amc.window.document.getElementById("contentFrame");
-
- let accountName = iframe.contentDocument.getElementById("server.prettyName");
- let defaultAddress = iframe.contentDocument.getElementById("identity.email");
- delete_all_existing(amc, new elib.Elem(accountName));
- delete_all_existing(amc, new elib.Elem(defaultAddress));
- input_value(amc, badName, new elib.Elem(accountName));
- input_value(amc, badEmail, new elib.Elem(defaultAddress));
-
- assert_equals(accountName.value, badName);
- assert_equals(defaultAddress.value, badEmail);
-
- // We really need to save the new values so click OK on the Account settings.
- amc.window.document.documentElement.querySelector("dialog").acceptDialog();
-}
deleted file mode 100644
--- a/mail/test/mozmill/account/test-archive-options.js
+++ /dev/null
@@ -1,209 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-var mozmill = ChromeUtils.import(
- "chrome://mozmill/content/modules/mozmill.jsm"
-);
-var controller = ChromeUtils.import(
- "chrome://mozmill/content/modules/controller.jsm"
-);
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-var utils = ChromeUtils.import("chrome://mozmill/content/modules/utils.jsm");
-
-var {
- click_account_tree_row,
- get_account_tree_row,
- open_advanced_settings,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/AccountManagerHelpers.jsm"
-);
-var { assert_equals, assert_false, assert_true, mc } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var {
- plan_for_modal_dialog,
- plan_for_window_close,
- wait_for_modal_dialog,
- wait_for_window_close,
-} = ChromeUtils.import("resource://testing-common/mozmill/WindowHelpers.jsm");
-
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-var defaultIdentity;
-
-function setupModule(module) {
- defaultIdentity = MailServices.accounts.defaultAccount.defaultIdentity;
-}
-
-/**
- * Check that the archive options button is enabled or disabled appropriately.
- *
- * @param amc the account options controller
- * @param aAccountKey key of the account the check
- * @param isEnabled true if the button should be enabled, false otherwise
- */
-function subtest_check_archive_options_enabled(amc, aAccountKey, isEnabled) {
- let accountRow = get_account_tree_row(aAccountKey, "am-copies.xhtml", amc);
- click_account_tree_row(amc, accountRow);
-
- let iframe = amc.window.document.getElementById("contentFrame");
- let button = iframe.contentDocument.getElementById("archiveHierarchyButton");
-
- assert_equals(button.disabled, !isEnabled);
-}
-
-function test_archive_options_enabled() {
- let defaultAccount = MailServices.accounts.defaultAccount;
- // First, create an IMAP server
- let imapServer = MailServices.accounts
- .createIncomingServer("nobody", "example.com", "imap")
- .QueryInterface(Ci.nsIImapIncomingServer);
-
- let identity = MailServices.accounts.createIdentity();
- identity.email = "tinderbox@example.com";
-
- let account = MailServices.accounts.createAccount();
- account.incomingServer = imapServer;
- account.addIdentity(identity);
-
- // Then test that the archive options button is enabled/disabled appropriately
-
- // Let the default identity archive to our IMAP folder, to ensure that the
- // archive folder's server is used to determine the enabled/disabled state
- // of the "archive options" button, *not* the incoming server for that
- // identity.
- defaultIdentity.archiveFolder = imapServer.rootFolder.URI;
-
- imapServer.isGMailServer = false;
- open_advanced_settings(function(amc) {
- subtest_check_archive_options_enabled(amc, account.key, true);
- });
- open_advanced_settings(function(amc) {
- subtest_check_archive_options_enabled(amc, defaultAccount.key, true);
- });
-
- imapServer.isGMailServer = true;
- open_advanced_settings(function(amc) {
- subtest_check_archive_options_enabled(amc, account.key, false);
- });
- open_advanced_settings(function(amc) {
- subtest_check_archive_options_enabled(amc, defaultAccount.key, false);
- });
-
- MailServices.accounts.removeAccount(account);
-}
-
-function subtest_initial_state(identity) {
- plan_for_modal_dialog("Mailnews:archiveOptions", function(ac) {
- assert_equals(
- ac.e("archiveGranularity").selectedIndex,
- identity.archiveGranularity
- );
- assert_equals(
- ac.e("archiveKeepFolderStructure").checked,
- identity.archiveKeepFolderStructure
- );
- });
- mc.window.openDialog(
- "chrome://messenger/content/am-archiveoptions.xhtml",
- "",
- "centerscreen,chrome,modal,titlebar,resizable=yes",
- identity
- );
- wait_for_modal_dialog("Mailnews:archiveOptions");
-}
-
-function test_open_archive_options() {
- for (let granularity = 0; granularity < 3; granularity++) {
- defaultIdentity.archiveGranularity = granularity;
- for (let kfs = 0; kfs < 2; kfs++) {
- defaultIdentity.archiveKeepFolderStructure = kfs;
- subtest_initial_state(defaultIdentity);
- }
- }
-}
-
-function subtest_save_state(identity, granularity, kfs) {
- plan_for_modal_dialog("Mailnews:archiveOptions", function(ac) {
- ac.e("archiveGranularity").selectedIndex = granularity;
- ac.e("archiveKeepFolderStructure").checked = kfs;
- ac.keypress(null, "VK_RETURN", {});
- ac.window.document.querySelector("dialog").acceptDialog();
- });
- mc.window.openDialog(
- "chrome://messenger/content/am-archiveoptions.xhtml",
- "",
- "centerscreen,chrome,modal,titlebar,resizable=yes",
- identity
- );
- wait_for_modal_dialog("Mailnews:archiveOptions");
-}
-
-function test_save_archive_options() {
- defaultIdentity.archiveGranularity = 0;
- defaultIdentity.archiveKeepFolderStructure = false;
- subtest_save_state(defaultIdentity, 1, true);
-
- assert_equals(defaultIdentity.archiveGranularity, 1);
- assert_equals(defaultIdentity.archiveKeepFolderStructure, true);
-}
-
-function subtest_check_archive_enabled(amc, archiveEnabled) {
- defaultIdentity.archiveEnabled = archiveEnabled;
-
- click_account_tree_row(amc, 2);
-
- let iframe = amc.window.document.getElementById("contentFrame");
- let checkbox = iframe.contentDocument.getElementById(
- "identity.archiveEnabled"
- );
-
- assert_equals(checkbox.checked, archiveEnabled);
-}
-
-function test_archive_enabled() {
- open_advanced_settings(function(amc) {
- subtest_check_archive_enabled(amc, true);
- });
-
- open_advanced_settings(function(amc) {
- subtest_check_archive_enabled(amc, false);
- });
-}
-
-function subtest_disable_archive(amc) {
- defaultIdentity.archiveEnabled = true;
- click_account_tree_row(amc, 2);
-
- let iframe = amc.window.document.getElementById("contentFrame");
- let checkbox = iframe.contentDocument.getElementById(
- "identity.archiveEnabled"
- );
-
- assert_true(checkbox.checked);
- assert_false(checkbox.disabled);
- amc.click(new elib.Elem(checkbox));
- utils.waitFor(
- () => !checkbox.checked,
- "Archive checkbox didn't toggle to unchecked"
- );
- plan_for_window_close(amc);
- amc.window.document.getElementById("accountManager").acceptDialog();
- wait_for_window_close();
-
- assert_false(defaultIdentity.archiveEnabled);
-}
-
-function test_disable_archive() {
- open_advanced_settings(subtest_disable_archive);
-}
-// Disable test on Windows since for some yet unknown reason clicking the checkbox
-// doesn't have the desired result. See bug 1461173 for details.
-test_disable_archive.EXCLUDED_PLATFORMS = ["winnt"];
deleted file mode 100644
--- a/mail/test/mozmill/account/test-mail-account-setup-wizard.js
+++ /dev/null
@@ -1,294 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-
-var {
- open_advanced_settings_from_account_wizard,
- open_mail_account_setup_wizard,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/AccountManagerHelpers.jsm"
-);
-var { assert_equals, mc } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { input_value, delete_all_existing } = ChromeUtils.import(
- "resource://testing-common/mozmill/KeyboardHelpers.jsm"
-);
-var { gMockPromptService } = ChromeUtils.import(
- "resource://testing-common/mozmill/PromptHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-var user = {
- name: "Yamato Nadeshiko",
- email: "yamato.nadeshiko@example.com",
- password: "abc12345",
- incomingHost: "testin.example.com",
- outgoingHost: "testout.example.com",
-};
-
-// Remove an account in the Account Manager, but not via the UI.
-function remove_account_internal(amc, aAccount, aOutgoing) {
- let win = amc.window;
-
- try {
- // Remove the account and incoming server
- let serverId = aAccount.incomingServer.serverURI;
- MailServices.accounts.removeAccount(aAccount);
- aAccount = null;
- if (serverId in win.accountArray) {
- delete win.accountArray[serverId];
- }
- win.selectServer(null, null);
-
- // Remove the outgoing server
- let smtpKey = aOutgoing.key;
- MailServices.smtp.deleteServer(aOutgoing);
- win.replaceWithDefaultSmtpServer(smtpKey);
- } catch (ex) {
- throw new Error("failure to remove account: " + ex + "\n");
- }
-}
-
-function test_mail_account_setup() {
- // Set the pref to load a local autoconfig file.
- let pref_name = "mailnews.auto_config_url";
- let url = collector.addHttpResource("../account/xml", "autoconfig");
- Services.prefs.setCharPref(pref_name, url);
-
- // Force .com MIME-Type to text/xml
- collector.httpd.registerContentType("com", "text/xml");
-
- open_mail_account_setup_wizard(function(awc) {
- // Input user's account information
- awc.click(awc.eid("realname"));
- if (awc.e("realname").value) {
- // If any realname is already filled, clear it out, we have our own.
- delete_all_existing(awc, awc.eid("realname"));
- }
- input_value(awc, user.name);
- awc.keypress(null, "VK_TAB", {});
- input_value(awc, user.email);
- awc.keypress(null, "VK_TAB", {});
- input_value(awc, user.password);
-
- // Load the autoconfig file from http://localhost:433**/autoconfig/example.com
- awc.click(awc.eid("next_button"));
-
- // XXX: This should probably use a notification, once we fix bug 561143.
- awc.waitFor(
- () => awc.window.gEmailConfigWizard._currentConfig != null,
- "Timeout waiting for current config to become non-null",
- 8000,
- 600
- );
-
- // Register the prompt service to handle the confirm() dialog
- gMockPromptService.register();
- gMockPromptService.returnValue = true;
-
- // Open the advanced settings (Account Manager) to create the account
- // immediately. We use an invalid email/password so the setup will fail
- // anyway.
- open_advanced_settings_from_account_wizard(subtest_verify_account, awc);
-
- let promptState = gMockPromptService.promptState;
- assert_equals("confirm", promptState.method);
-
- // Clean up
- gMockPromptService.unregister();
- Services.prefs.clearUserPref(pref_name);
- });
-}
-
-function subtest_verify_account(amc) {
- amc.waitFor(
- () => amc.window.currentAccount != null,
- "Timeout waiting for currentAccount to become non-null"
- );
- let account = amc.window.currentAccount;
- let identity = account.defaultIdentity;
- let incoming = account.incomingServer;
- let outgoing = MailServices.smtp.getServerByKey(identity.smtpServerKey);
-
- let config = {
- "incoming server username": {
- actual: incoming.username,
- expected: user.email.split("@")[0],
- },
- "outgoing server username": {
- actual: outgoing.username,
- expected: user.email,
- },
- "incoming server hostname": {
- // Note: N in the hostName is uppercase
- actual: incoming.hostName,
- expected: user.incomingHost,
- },
- "outgoing server hostname": {
- // And this is lowercase
- actual: outgoing.hostname,
- expected: user.outgoingHost,
- },
- "user real name": { actual: identity.fullName, expected: user.name },
- "user email address": { actual: identity.email, expected: user.email },
- };
-
- try {
- for (let i in config) {
- if (config[i].actual != config[i].expected) {
- throw new Error(
- "Configured " +
- i +
- " is " +
- config[i].actual +
- ". It should be " +
- config[i].expected +
- "."
- );
- }
- }
- } finally {
- remove_account_internal(amc, account, outgoing);
- }
-}
-
-/**
- * Make sure that we don't re-set the information we get from the config
- * file if the password is incorrect.
- */
-function test_bad_password_uses_old_settings() {
- // Set the pref to load a local autoconfig file, that will fetch the
- // ../account/xml/example.com which contains the settings for the
- // @example.com email account (see the 'user' object).
- let pref_name = "mailnews.auto_config_url";
- let url = collector.addHttpResource("../account/xml", "autoconfig");
- Services.prefs.setCharPref(pref_name, url);
-
- // Force .com MIME-Type to text/xml
- collector.httpd.registerContentType("com", "text/xml");
-
- mc.sleep(0);
- open_mail_account_setup_wizard(function(awc) {
- try {
- // Input user's account information
- awc.click(awc.eid("realname"));
- if (awc.e("realname").value) {
- // If any realname is already filled, clear it out, we have our own.
- delete_all_existing(awc, awc.eid("realname"));
- }
- input_value(awc, user.name);
- awc.keypress(null, "VK_TAB", {});
- input_value(awc, user.email);
- awc.keypress(null, "VK_TAB", {});
- input_value(awc, user.password);
-
- // Load the autoconfig file from http://localhost:433**/autoconfig/example.com
- awc.e("next_button").click();
-
- awc.waitFor(
- function() {
- return !this.disabled && !this.hidden;
- },
- "Timeout waiting for create button to be visible and active",
- 8000,
- 600,
- awc.e("create_button")
- );
- awc.e("create_button").click();
-
- awc.waitFor(
- function() {
- return !this.disabled;
- },
- "Timeout waiting for create button to be visible and active",
- 8000,
- 600,
- awc.e("create_button")
- );
- awc.e("create_button").click();
- awc.e("manual-edit_button").click();
-
- // Make sure all the values are the same as in the user object.
- awc.sleep(1000);
- assert_equals(
- awc.e("outgoing_hostname").value,
- user.outgoingHost,
- "Outgoing server changed!"
- );
- assert_equals(
- awc.e("incoming_hostname").value,
- user.incomingHost,
- "incoming server changed!"
- );
- } finally {
- // Clean up
- Services.prefs.clearUserPref(pref_name);
- awc.e("cancel_button").click();
- }
- });
-}
-
-function test_remember_password() {
- remember_password_test(true);
- remember_password_test(false);
-}
-
-/**
- * Test remember_password checkbox behavior with
- * signon.rememberSignons set to "aPrefValue"
- */
-function remember_password_test(aPrefValue) {
- // save the pref for backup purpose
- let rememberSignons_pref_save = Services.prefs.getBoolPref(
- "signon.rememberSignons",
- true
- );
-
- Services.prefs.setBoolPref("signon.rememberSignons", aPrefValue);
-
- // without this, it breaks the test, don't know why
- mc.sleep(0);
- open_mail_account_setup_wizard(function(awc) {
- try {
- let password = new elementslib.ID(awc.window.document, "password");
- let rememberPassword = new elementslib.ID(
- awc.window.document,
- "remember_password"
- );
-
- // type something in the password field
- awc.e("password").focus();
- input_value(awc, "testing");
-
- awc.assertProperty(rememberPassword, "disabled", !aPrefValue);
- if (aPrefValue) {
- awc.assertChecked(rememberPassword);
- } else {
- awc.assertNotChecked(rememberPassword);
- }
-
- // empty the password field
- delete_all_existing(awc, password);
-
- // restore the saved signon.rememberSignons value
- Services.prefs.setBoolPref(
- "signon.rememberSignons",
- rememberSignons_pref_save
- );
- } finally {
- // close the wizard
- awc.e("cancel_button").click();
- }
- });
-}
deleted file mode 100644
--- a/mail/test/mozmill/account/test-retest-config.js
+++ /dev/null
@@ -1,121 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-
-var { open_mail_account_setup_wizard } = ChromeUtils.import(
- "resource://testing-common/mozmill/AccountManagerHelpers.jsm"
-);
-var { assert_true, mc } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { input_value, delete_all_existing } = ChromeUtils.import(
- "resource://testing-common/mozmill/KeyboardHelpers.jsm"
-);
-var { close_window } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var user = {
- name: "test",
- email: "test@momo.invalid",
- altEmail: "test2@momo.invalid",
-};
-
-function setupModule(module) {
- Services.prefs.setCharPref("mail.wizard.logging.dump", "All");
-
- let url = collector.addHttpResource("../account/xml", "accountconfig");
- Services.prefs.setCharPref("mailnews.auto_config_url", url);
- collector.httpd.registerContentType("invalid", "text/xml");
-}
-
-function tearDownModule(module) {
- Services.prefs.clearUserPref("mailnews.auto_config_url");
- Services.prefs.clearUserPref("mail.wizard.logging.dump");
-}
-
-function test_re_test_config() {
- // Opening multiple windows in the same run seems to require letting the stack
- // unwind before opening the next one, so do that here.
- mc.sleep(0);
- open_mail_account_setup_wizard(function(awc) {
- // Input user's account information
- awc.click(awc.eid("realname"));
- if (awc.e("realname").value) {
- // If any realname is already filled, clear it out, we have our own.
- delete_all_existing(awc, awc.eid("realname"));
- }
- input_value(awc, user.name);
- awc.keypress(null, "VK_TAB", {});
- input_value(awc, user.email);
-
- // Click "continue" button
- awc.e("next_button").click();
-
- // Wait for 'edit' button to be enabled
- awc.waitFor(
- function() {
- return !this.disabled && !this.hidden;
- },
- "Timeout waiting for edit button to be enabled",
- 8000,
- 600,
- awc.e("create_button")
- );
-
- awc.e("manual-edit_button").click();
-
- // Click "re-test" button
- awc.e("half-manual-test_button").click();
-
- awc.waitFor(
- function() {
- return !this.disabled;
- },
- "Timeout waiting for re-test button to be enabled",
- 20000,
- 600,
- awc.e("half-manual-test_button")
- );
-
- // There used to be a "start over" button (line commented out below). Now just
- // changing the value of the email field does the trick.
- awc.e("realname").focus();
- awc.keypress(null, "VK_TAB", {});
- awc.e("email").focus();
- input_value(awc, user.altEmail);
- awc.keypress(null, "VK_TAB", {});
-
- // Wait for the "continue" button to be back, which means we're back to the
- // original state.
- awc.waitFor(
- function() {
- return !this.hidden;
- },
- "Timeout waiting for continue button to be visible",
- 20000,
- 600,
- awc.e("next_button")
- );
-
- awc.e("next_button").click();
-
- // Previously, we'd switched to the manual editing state. Now we've started
- // over, we should make sure the information is presented back in its original
- // "automatic" mode.
- assert_true(
- awc.e("manual-edit_area").hidden,
- "We're not back to the original state!"
- );
-
- close_window(awc);
- });
-}
deleted file mode 100644
--- a/mail/test/mozmill/account/xml/example.com
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<clientConfig>
- <emailProvider id="example.com">
- <domain>example.com</domain>
- <displayName>Example</displayName>
- <displayShortName>Example</displayShortName>
- <incomingServer type="pop3">
- <hostname>testin.%EMAILDOMAIN%</hostname>
- <port>995</port>
- <socketType>SSL</socketType>
- <username>%EMAILLOCALPART%</username>
- <authentication>plain</authentication>
- </incomingServer>
- <outgoingServer type="smtp">
- <hostname>testout.%EMAILDOMAIN%</hostname>
- <port>587</port>
- <socketType>STARTTLS</socketType>
- <username>%EMAILADDRESS%</username>
- <authentication>plain</authentication>
- <addThisServer>true</addThisServer>
- <useGlobalPreferredServer>false</useGlobalPreferredServer>
- </outgoingServer>
- </emailProvider>
-</clientConfig>
deleted file mode 100644
--- a/mail/test/mozmill/account/xml/momo.invalid
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<clientConfig version="1.1">
- <emailProvider id="momo.invalid">
- <domain>momo.invalid</domain>
- <displayName>MoMo Mail</displayName>
- <displayShortName>Yahoo</displayShortName>
- <incomingServer type="pop3">
- <hostname>pop.mail.momo.invalid</hostname>
- <port>995</port>
- <socketType>SSL</socketType>
- <username>%EMAILLOCALPART%</username>
- <authentication>password-cleartext</authentication>
- </incomingServer>
- <incomingServer type="imap">
- <hostname>imap.mail.momo.invalid</hostname>
- <port>993</port>
- <socketType>SSL</socketType>
- <username>%EMAILLOCALPART%</username>
- <authentication>password-cleartext</authentication>
- </incomingServer>
- <outgoingServer type="smtp">
- <hostname>smtp.mail.momo.invalid</hostname>
- <port>465</port>
- <socketType>SSL</socketType>
- <username>%EMAILLOCALPART%</username>
- <authentication>password-cleartext</authentication>
- </outgoingServer>
- </emailProvider>
-</clientConfig>
deleted file mode 100644
--- a/mail/test/mozmill/addrbook/test-address-book-panes.js
+++ /dev/null
@@ -1,136 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Tests for the address book.
- */
-
-"use strict";
-
-var {
- close_address_book_window,
- open_address_book_window,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/AddressBookHelpers.jsm"
-);
-
-var abController;
-
-function setupModule(module) {
- // Open the address book main window
- abController = open_address_book_window();
-}
-
-function teardownModule(module) {
- // Make sure the panes are all visible now that we're
- // done these tests.
- toggle_directory_pane();
- toggle_contact_pane();
-
- assert_directory_pane_visibility(true);
- assert_contact_pane_visibility(true);
-
- close_address_book_window(abController);
-}
-
-/**
- * Helper function to toggle a pane.
- *
- * @param splitterId the id of the splitter to toggle
- */
-function _help_toggle_pane(splitterId) {
- abController.window.togglePaneSplitter(splitterId);
-}
-
-/**
- * Helper function to check consistency of a pane's state.
- *
- * @param paneId the id of the pane in question
- * @param menuitemId the id of the menuitem corresponding to the pane
- * @param visible true if the pane should be visible, false otherwise
- */
-function _help_assert_pane_visibility(paneId, menuitemId, visible) {
- if (abController.e(paneId).collapsed == visible) {
- throw new Error(
- paneId + " pane should be " + (visible ? "visible" : "hidden")
- );
- }
-
- abController.window.InitViewLayoutMenuPopup();
- if (
- (abController.e(menuitemId).getAttribute("checked") == "true") !=
- visible
- ) {
- throw new Error(
- menuitemId + " menuitem should be " + (visible ? "checked" : "unchecked")
- );
- }
-}
-
-/**
- * Toggle the directory pane.
- */
-function toggle_directory_pane() {
- _help_toggle_pane("dirTree-splitter");
-}
-
-/**
- * Toggle the contact pane.
- */
-function toggle_contact_pane() {
- _help_toggle_pane("results-splitter");
-}
-
-/**
- * Check that the directory pane is visible or hidden.
- *
- * @param visible true if the pane should be visible, false otherwise
- */
-function assert_directory_pane_visibility(visible) {
- _help_assert_pane_visibility("dirTreeBox", "menu_showDirectoryPane", visible);
-}
-
-/**
- * Check that the contact pane is visible or hidden.
- *
- * @param visible true if the pane should be visible, false otherwise
- */
-function assert_contact_pane_visibility(visible) {
- _help_assert_pane_visibility(
- "CardViewOuterBox",
- "menu_showCardPane",
- visible
- );
-}
-
-function test_hide_directory_pane() {
- toggle_directory_pane();
- assert_directory_pane_visibility(false);
-}
-
-function test_show_directory_pane() {
- toggle_directory_pane();
- assert_directory_pane_visibility(true);
-}
-
-function test_hide_contact_pane() {
- toggle_contact_pane();
- assert_contact_pane_visibility(false);
-}
-
-function test_show_contact_pane() {
- toggle_contact_pane();
- assert_contact_pane_visibility(true);
-}
-
-function test_persist_panes() {
- toggle_directory_pane();
- toggle_contact_pane();
-
- close_address_book_window(abController);
- abController = open_address_book_window();
-
- assert_directory_pane_visibility(false);
- assert_contact_pane_visibility(false);
-}
deleted file mode 100644
--- a/mail/test/mozmill/addrbook/test-address-book.js
+++ /dev/null
@@ -1,403 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Tests for the address book.
- */
-
-"use strict";
-
-var {
- close_address_book_window,
- create_address_book,
- create_contact,
- create_ldap_address_book,
- create_mailing_list,
- get_name_of_address_book_element_at,
- is_address_book_collapsed,
- load_contacts_into_address_book,
- load_contacts_into_mailing_list,
- open_address_book_window,
- select_address_book,
- select_contacts,
- set_address_books_collapsed,
- set_address_books_expanded,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/AddressBookHelpers.jsm"
-);
-var { wait_for_compose_window } = ChromeUtils.import(
- "resource://testing-common/mozmill/ComposeHelpers.jsm"
-);
-var {
- assert_equals,
- assert_false,
- assert_not_equals,
- assert_true,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { gMockPromptService } = ChromeUtils.import(
- "resource://testing-common/mozmill/PromptHelpers.jsm"
-);
-var { plan_for_new_window } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { XPCOMUtils } = ChromeUtils.import(
- "resource://gre/modules/XPCOMUtils.jsm"
-);
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-var abController = null;
-var addrBook1, addrBook2, addrBook3, addrBook4, ldapBook;
-var mListA, mListB, mListC, mListD, mListE;
-
-function setupModule(module) {
- // Open the address book main window
- abController = open_address_book_window();
-
- // Let's add some new address books. I'll add them
- // out of order to properly test the alphabetical
- // ordering of the address books.
- ldapBook = create_ldap_address_book("LDAP Book");
- addrBook3 = create_address_book("AB 3");
- addrBook1 = create_address_book("AB 1");
- addrBook4 = create_address_book("AB 4");
- addrBook2 = create_address_book("AB 2");
-
- mListA = create_mailing_list("ML A");
- addrBook1.addMailList(mListA);
-
- mListB = create_mailing_list("ML B");
- addrBook2.addMailList(mListB);
-
- mListC = create_mailing_list("ML C");
- addrBook3.addMailList(mListC);
-
- mListD = create_mailing_list("ML D");
- addrBook3.addMailList(mListD);
-
- // There are 8 address book lists (All, Personal, AB 1, AB 2, AB 3, AB 4, LDAP Book
- // and Collected Address Book. So let's ensure that those address books
- // exist in the tree view before executing our tests.
- abController.waitFor(
- () => abController.window.gDirectoryTreeView.rowCount == 8,
- "Timeout waiting for all 8 rows in address books list to show up in the tree view",
- 1000,
- 10
- );
-}
-
-function teardownModule(module) {
- close_address_book_window(abController);
-}
-
-/* Test that the address book manager automatically sorts
- * address books.
- *
- * Currently, we sort address books as follows:
- * 1. All Address Books
- * 2. Personal Address Book
- * 3. Mork Address Books
- * 4. LDAP / Other Address Books
- * 5. Collected Address Book
- *
- * With the All, Personal and Collapsed address books existing
- * automatically, our address books *should* be in this order:
- *
- * All Address Books
- * Personal Address Book
- * AB 1
- * ML A
- * AB 2
- * ML B
- * AB 3
- * ML C
- * ML D
- * AB 4
- * LDAP Book
- * Collected Address Book
- **/
-function test_order_of_address_books() {
- const EXPECTED_AB_ORDER = [
- "All Address Books",
- "Personal Address Book",
- "AB 1",
- "AB 2",
- "AB 3",
- "AB 4",
- "LDAP Book",
- "Collected Addresses",
- ];
-
- for (let i = 0; i < EXPECTED_AB_ORDER.length; i++) {
- let abName = get_name_of_address_book_element_at(i);
- assert_equals(
- abName,
- EXPECTED_AB_ORDER[i],
- "The address books are out of order."
- );
- }
-}
-
-/* Test that the expanded and collapsed states of address books
- * in the tree persist state when closing and re-opening the
- * address book manager
- */
-function test_persist_collapsed_and_expanded_states() {
- // Set the state of address books 1 and 3 to expanded
- set_address_books_expanded([addrBook1, addrBook3]);
-
- // Set address book 2 to be collapsed
- set_address_books_collapsed(addrBook2);
-
- // Now close and re-open the address book
- close_address_book_window(abController);
- abController = open_address_book_window();
-
- assert_true(is_address_book_collapsed(addrBook2));
- assert_true(!is_address_book_collapsed(addrBook1));
- assert_true(!is_address_book_collapsed(addrBook3));
-
- // Now set the state of address books 1 and 3 to collapsed
- // and make sure 2 is expanded
- set_address_books_collapsed([addrBook1, addrBook3]);
- set_address_books_expanded(addrBook2);
-
- // Now close and re-open the address book
- close_address_book_window(abController);
- abController = open_address_book_window();
-
- assert_true(!is_address_book_collapsed(addrBook2));
- assert_true(is_address_book_collapsed(addrBook1));
- assert_true(is_address_book_collapsed(addrBook3));
-}
-
-/* Test that if we try to delete a contact, that we are given
- * a confirm prompt.
- */
-function test_deleting_contact_causes_confirm_prompt() {
- // Register the Mock Prompt Service
- gMockPromptService.register();
-
- // Create a contact that we'll try to delete
- let contact1 = create_contact("test@example.com", "Sammy Jenkis", true);
- let toDelete = [contact1];
-
- let bundle = Services.strings.createBundle(
- "chrome://messenger/locale/addressbook/addressBook.properties"
- );
- let confirmSingle = bundle.GetStringFromName("confirmDeleteThisContact");
- confirmSingle = confirmSingle.replace("#1", "Sammy Jenkis");
-
- // Add some contacts to the address book
- load_contacts_into_address_book(addrBook1, toDelete);
- select_address_book(addrBook1);
-
- let totalEntries = abController.window.gAbView.rowCount;
-
- // Set the mock prompt to return false, so that the
- // contact should not be deleted.
- gMockPromptService.returnValue = false;
-
- // Now attempt to delete the contact
- select_contacts(toDelete);
- abController.keypress(null, "VK_DELETE", {});
-
- let promptState = gMockPromptService.promptState;
- assert_not_equals(null, promptState, "Expected a prompt state");
- // Was a confirm displayed?
- assert_equals("confirm", promptState.method);
- // Was the right message displayed?
- assert_equals(confirmSingle, promptState.text);
- // The contact should not have been deleted.
- assert_equals(abController.window.gAbView.rowCount, totalEntries);
-
- gMockPromptService.reset();
-
- // Now we'll return true on confirm so that
- // the contact is deleted.
- gMockPromptService.returnValue = true;
- select_contacts(toDelete);
- abController.keypress(null, "VK_DELETE", {});
-
- promptState = gMockPromptService.promptState;
- assert_not_equals(null, promptState, "Expected a prompt state");
- // Was a confirm displayed?
- assert_equals("confirm", promptState.method);
- // Was the right message displayed?
- assert_equals(confirmSingle, promptState.text);
- // The contact should have been deleted.
- assert_equals(
- abController.window.gAbView.rowCount,
- totalEntries - toDelete.length
- );
-
- gMockPromptService.unregister();
-}
-
-/* Test that if we try to delete multiple contacts, that we are give
- * a confirm prompt.
- */
-function test_deleting_contacts_causes_confirm_prompt() {
- // Register the Mock Prompt Service
- gMockPromptService.register();
-
- // Create some contacts that we'll try to delete.
- let contact2 = create_contact("test2@example.com", "Leonard Shelby", true);
- let contact3 = create_contact(
- "test3@example.com",
- "John Edward Gammell",
- true
- );
- let contact4 = create_contact("test4@example.com", "Natalie", true);
-
- let toDelete = [contact2, contact3, contact4];
-
- let bundle = Services.strings.createBundle(
- "chrome://messenger/locale/addressbook/addressBook.properties"
- );
- let confirmMultiple = bundle.GetStringFromName(
- "confirmDelete2orMoreContacts"
- );
- confirmMultiple = confirmMultiple.replace(/.*;/, "").replace("#1", "3");
-
- // Add some contacts to the address book
- load_contacts_into_address_book(addrBook1, toDelete);
- select_address_book(addrBook1);
-
- let totalEntries = abController.window.gAbView.rowCount;
-
- // Set the mock prompt to return false, so that the
- // contact should not be deleted.
- gMockPromptService.returnValue = false;
-
- // Now attempt to delete the contact
- select_contacts(toDelete);
- abController.keypress(null, "VK_DELETE", {});
-
- let promptState = gMockPromptService.promptState;
- assert_not_equals(null, promptState, "Expected a prompt state");
- // Was a confirm displayed?
- assert_equals("confirm", promptState.method);
- // Was the right message displayed?
- assert_equals(confirmMultiple, promptState.text);
- // The contact should not have been deleted.
- assert_equals(abController.window.gAbView.rowCount, totalEntries);
-
- gMockPromptService.reset();
-
- // Now we'll return true on confirm so that
- // the contact is deleted.
- gMockPromptService.returnValue = true;
- select_contacts(toDelete);
- abController.keypress(null, "VK_DELETE", {});
-
- promptState = gMockPromptService.promptState;
- assert_not_equals(null, promptState, "Expected a prompt state");
- // Was a confirm displayed?
- assert_equals("confirm", promptState.method);
- // Was the right message displayed?
- assert_equals(confirmMultiple, promptState.text);
- // The contact should have been deleted.
- assert_equals(
- abController.window.gAbView.rowCount,
- totalEntries - toDelete.length
- );
-
- gMockPromptService.unregister();
-}
-
-/* Tests that attempting to delete a mailing list causes a
- * confirmation dialog to be brought up, and that deletion
- * actually works if the user clicks "OK".
- */
-function test_deleting_mailing_lists() {
- // Register our Mock Prompt Service
- gMockPromptService.register();
-
- // Create a new mailing list, and add it to one of our
- // address books
- let newList = create_mailing_list("Delete Me!");
- let addedList = addrBook1.addMailList(newList);
-
- // Make sure it got added.
- assert_true(addrBook1.hasDirectory(addedList));
-
- // Let's click "cancel" on the confirm dialog box
- // first.
- gMockPromptService.returnValue = false;
-
- abController.window.AbDeleteDirectory(addedList.URI);
-
- let promptState = gMockPromptService.promptState;
- assert_not_equals(null, promptState, "Expected a prompt state");
-
- // Test that the confirmation dialog was brought up.
- assert_equals("confirm", promptState.method);
-
- // Ensure that the mailing list was not removed.
- assert_true(addrBook1.hasDirectory(addedList));
-
- // This time, let's click "OK" on the confirm dialog box
- gMockPromptService.reset();
- gMockPromptService.returnValue = true;
-
- abController.window.AbDeleteDirectory(addedList.URI);
-
- // Test that the confirmation dialog was brought up.
- promptState = gMockPromptService.promptState;
- assert_not_equals(null, promptState, "Expected a prompt state");
- assert_equals("confirm", promptState.method);
-
- // Ensure that the mailing list was removed.
- assert_false(addrBook1.hasDirectory(addedList));
-
- gMockPromptService.unregister();
-}
-
-/* Tests that we can send mail to a mailing list by selecting the
- * mailing list in the tree, and clicking "Write"
- */
-function test_writing_to_mailing_list() {
- // Create a new mailing list, and add it to one of our
- // address books
- let newList = create_mailing_list("Some Mailing List");
- let addedList = addrBook1.addMailList(newList);
-
- // Create some contacts that we'll try to contact
- let contacts = [
- create_contact("test2@example.com", "Leonard Shelby", true),
- create_contact("test3@example.com", "John Edward Gammell", true),
- create_contact("test4@example.com", "Natalie", true),
- ];
-
- load_contacts_into_mailing_list(addedList, contacts);
-
- // Ensure that addrBook1 is expanded
- set_address_books_expanded(addrBook1);
-
- // Now select the mailing list in the tree...
- select_address_book(addedList);
-
- // Focus it...
- abController.window.gDirTree.focus();
-
- // Assuming we've made it this far, now we just plan for the compose
- // window...
- plan_for_new_window("msgcompose");
- // ... and click the "Write" button
- abController.click(abController.eid("button-newmessage"));
- let composeWin = wait_for_compose_window(abController);
- let to = composeWin.window.gMsgCompose.compFields.to;
-
- // Make sure we're writing to all contacts in the mailing list.
- for (let contact of contacts) {
- assert_true(to.includes(contact.primaryEmail));
- assert_true(to.includes(contact.displayName));
- }
-}
deleted file mode 100644
--- a/mail/test/mozmill/addrbook/test-update-mailing-list.js
+++ /dev/null
@@ -1,80 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests that if a contact's address is updated, then the address is also
- * updated in mailing lists that that contact belongs to.
- */
-
-"use strict";
-
-var {
- accept_contact_changes,
- close_address_book_window,
- create_address_book,
- create_contact,
- create_mailing_list,
- delete_address_book,
- edit_selected_contact,
- open_address_book_window,
- select_address_book,
- select_contacts,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/AddressBookHelpers.jsm"
-);
-var { assert_equals, mc } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-function test_contact_in_mailing_list_updated() {
- const kOldAddress = "before@example.com";
- const kNewAddress = "after@example.com";
-
- // Create some address book to work with...
- let ab = create_address_book("Some Address Book");
- // And a contact...
- let contact = create_contact(kOldAddress, "Some Contact", true);
- // And our mailing list.
- let ml = create_mailing_list("Some Mailing List");
-
- // Add the mailing list to the address book, and then the card to the
- // address book, and finally, the card to the mailing list.
- ml = ab.addMailList(ml);
- contact = ml.addCard(contact);
-
- // Open the address book, select our contact...
- let abw = open_address_book_window(mc);
- select_address_book(ab);
- select_contacts(contact);
-
- // Change the primary email address of the contact...
- edit_selected_contact(abw, function(ecw) {
- ecw.e("PrimaryEmail").value = kNewAddress;
- accept_contact_changes(ecw);
- });
-
- // Because the current address book is kind of lame, in order
- // to see whether or not the mailing list contact was updated,
- // we have to get a fresh copy of the address book...
- ab = MailServices.ab.getDirectory(ab.URI);
-
- // Ensure that the primary email address for the contact changed
- // in the mailing list as well.
- assert_equals(
- 1,
- ml.addressLists.length,
- "There should only be one contact in the mailing list"
- );
- let mlContact = ml.addressLists.queryElementAt(0, Ci.nsIAbCard);
- assert_equals(kNewAddress, mlContact.primaryEmail);
-
- // Destroy the address book that we created.
- delete_address_book(ab);
-
- close_address_book_window(abw);
-}
deleted file mode 100644
--- a/mail/test/mozmill/attachment/attachment.txt
+++ /dev/null
@@ -1,1 +0,0 @@
-This is a test attachment! It sure is exciting!
deleted file mode 100644
--- a/mail/test/mozmill/attachment/bug1358565.eml
+++ /dev/null
@@ -1,62 +0,0 @@
-Date: Thu, 22 Feb 2017 10:00:00 -0300
-From: <nobody@example.com>
-MIME-Version: 1.0
-To: <nobody2@example.com>
-Content-Type: multipart/alternative; boundary="------alternative"
-Subject: thunderbird bug
-
-
---------alternative
-Content-Type: text/plain;
- charset=US-ASCII;
- format=flowed
-Content-Transfer-Encoding: 7bit
-
-text plain part.
-
---------alternative
-Content-Type: multipart/related;
- boundary="------related";
- type="text/html"
-
---------related
-Content-Type: text/html;
- charset=US-ASCII
-Content-Transfer-Encoding: 7bit
-
-<html><body>HTML part<br><img src="cid:bug.png"></body></html>
---------related
-Content-Disposition: inline;
- filename=bug.png
-Content-Transfer-Encoding: base64
-Content-Type: image/jpeg;
- name="bug.png"
-Content-Id: <bug.png>
-
-iVBORw0KGgoAAAANSUhEUgAAAHYAAABNCAYAAABzGpB/AAAABGdBTUEAALGPC/xhBQAAAAFzUkdC
-AK7OHOkAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAS/SURBVHja7Zy/TexAEIdPJKQkhDQAJRBQAhk5
-GQWQ0QARBSBRAVRAAQRkpERIFEAJfvqeZOnOzHj/2l4fv5+00ruz18/M55kd787eppP2UhuZQGAl
-gZUEVhJYSWAFVib4o2BPTk66zWaz056fn2U5gZUEVhJYSWAFVmAFVpYTWElgJYGVBFZgBVZgZTmB
-lVYP9v39vbu9ve1OT0+7w8PDnT585loc57y/pM/Pz+7h4aG7urrqjo+Pd+xycXHR3dzcdK+vr93P
-z09bYL++vrrz8/Nf5401zs8FbN3T9fV1kSH4m4bX5P8pEbDOzs6ibQL0l5eXXUDGeR8fH9ODfXx8
-7A4ODpKg9o1+9/f3ewcWz8M7c2xCo2/vvYuABUruzW+3VLgtgyXsDsNtTiNELwLWMgQeSIjFyP05
-QLu8vPw15pYkZK2CxcvGoHLs7u6ue3p6+g+HRujlO6sf4/KsYIfhl39jWMbaMQHZC9t8H+rfOli8
-zAPKeBsSkGO8fTKw23COjo6ibno70aKPdcOxcFoEixd6IfX7+7tqKJ8M7DbgnMwWuJbnxnpta2C9
-EExGnPMKE4I7OdiSiQov8eI9d21gPW+NAeDp7e1tGbAkSaWyEqoYY7YG1npXJSEqlTdmTwo2ZVz1
-hHda114TWMKm9Tfwfamw8axg8bQaYnzOCfEtgbXCMB5cQyRds4KtEYZ7WUlUaJxtCaw1w8T7Z7U5
-3znBlhqx9PotgbWyVxKfVYKtuWy3drC1s2GBbQCslzjVlMAuABYDC6zACqzA7gFYa0FAYPcA7Jon
-KLzkabVZccxEfa4xaaEVoynA0r/W606N6dbSBycLLBURNcR1cqYrp7gnqxgvBuxUCwCrniu2Vndi
-pitzvSv1XmKuCUSrYqKGvIK4SVd3SsdZbz2WspuQvFWh2NKa2CEhBqznVaXh2AvDk4Mlm80VACwP
-iY0EHoicUtaxvzEGLBUSVt/c6omQt85SQZG7yuMVl6eAsVaFeDBSvdbz/pTwboXjkrHWq06cDWwO
-XA9qagTwrpNyP6G66Fiw3rppDlyvzGb2KsXeAKFXFI6PPSSpY5IXjmnsHRrzXI4NEzD6TFGl2Ff2
-hyoVOT4Mv4vXFW97HQbjeF8szmev3LR0bLRgDGFtF68TdvFo68GsUVcc2tZBDRMPAOu1wOFh5rNV
-28R33vg96cwTN5W7Z6cG1N7zQg9NqNGf69TaCeAVoKVu71h0704JXPrFvNqERIjPhdtDzZ1S9OCy
-LbLGhqxF54oxbCgkWvt7ct85Pc+1ZrHG2nBLSu1tlITblC2UnDvcQjkp2BTPwVgYwxrDgEnYrQnU
-Ajy28ZrvOT7lPViA+03PlneSNY/VSC0OVppGucuCAtuwStZ7BbZhMeZa4VtgVy4ru44tRhfYRuVN
-TsQWowtso7KmKFPWeQW2QXlrsSkLCgLbYAj2piVTfvJAYCuJbLV0MxavN95PFKTu4BPYyhMJTA0C
-IaUEldDrLdYPFwUEdiGw1nsnoEmGho3XmdB8Mh6cszteYCcGW7p8l/uTBwLbKFi8vKQYTmAriYyV
-8JqyVOf9JF9K9iuwM0OmCKFfrvNgc4zW/7Zi1QgiDHs6NMgEAisJrCSwksBK8foHNXX2LMmMFTgA
-AAAASUVORK5CYII=
---------related--
-
---------alternative--
deleted file mode 100644
--- a/mail/test/mozmill/attachment/test-attachment-events.js
+++ /dev/null
@@ -1,437 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Ensures that attachment events are fired properly
- */
-
-"use strict";
-
-var os = ChromeUtils.import("chrome://mozmill/content/stdlib/os.jsm");
-
-var { select_attachments } = ChromeUtils.import(
- "resource://testing-common/mozmill/AttachmentHelpers.jsm"
-);
-var { assert_equals, assert_true, mc } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var {
- add_attachments,
- close_compose_window,
- open_compose_new_mail,
-} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
-var { gMockPromptService } = ChromeUtils.import(
- "resource://testing-common/mozmill/PromptHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var { fixIterator } = ChromeUtils.import(
- "resource:///modules/iteratorUtils.jsm"
-);
-
-var kAttachmentsAdded = "attachments-added";
-var kAttachmentsRemoved = "attachments-removed";
-var kAttachmentRenamed = "attachment-renamed";
-
-var gPath;
-
-function setupModule(module) {
- gPath = os.getFileForPath(__file__);
-}
-
-/**
- * Test that the attachments-added event is fired when we add a single
- * attachment.
- */
-function test_attachments_added_on_single() {
- // Prepare to listen for attachments-added
- let eventCount = 0;
- let lastEvent;
- let listener = function(event) {
- eventCount++;
- lastEvent = event;
- };
-
- // Open up the compose window
- let cw = open_compose_new_mail(mc);
- cw.e("attachmentBucket").addEventListener(kAttachmentsAdded, listener);
-
- // Attach a single file
- add_attachments(cw, "http://www.example.com/1", 0, false);
-
- // Make sure we only saw the event once
- assert_equals(1, eventCount);
-
- // Make sure that we were passed the right subject
- let subjects = lastEvent.detail;
- assert_true(subjects instanceof Ci.nsIMutableArray);
- assert_equals(
- "http://www.example.com/1",
- subjects.queryElementAt(0, Ci.nsIMsgAttachment).url
- );
-
- // Make sure that we can get that event again if we
- // attach more files.
- add_attachments(cw, "http://www.example.com/2", 0, false);
- assert_equals(2, eventCount);
- subjects = lastEvent.detail;
- assert_true(subjects instanceof Ci.nsIMutableArray);
- assert_equals(
- "http://www.example.com/2",
- subjects.queryElementAt(0, Ci.nsIMsgAttachment).url
- );
-
- // And check that we don't receive the event if we try to attach a file
- // that's already attached.
- add_attachments(cw, "http://www.example.com/2", null, false);
- assert_equals(2, eventCount);
-
- cw.e("attachmentBucket").removeEventListener(kAttachmentsAdded, listener);
- close_compose_window(cw);
-}
-
-/**
- * Test that the attachments-added event is fired when we add a series
- * of files all at once.
- */
-function test_attachments_added_on_multiple() {
- // Prepare to listen for attachments-added
- let eventCount = 0;
- let lastEvent;
- let listener = function(event) {
- eventCount++;
- lastEvent = event;
- };
-
- // Prepare the attachments - we store the names in attachmentNames to
- // make sure that we observed the right event subjects later on.
- let attachmentUrls = ["http://www.example.com/1", "http://www.example.com/2"];
-
- // Open the compose window and add the attachments
- let cw = open_compose_new_mail(mc);
- cw.e("attachmentBucket").addEventListener(kAttachmentsAdded, listener);
-
- add_attachments(cw, attachmentUrls, null, false);
-
- // Make sure we only saw a single attachments-added for this group
- // of files.
- assert_equals(1, eventCount);
-
- // Now make sure we got passed the right subjects for the event
- let subjects = lastEvent.detail;
- assert_true(subjects instanceof Ci.nsIMutableArray);
- assert_equals(2, subjects.length);
-
- for (let attachment of fixIterator(subjects, Ci.nsIMsgAttachment)) {
- assert_true(attachmentUrls.includes(attachment.url));
- }
-
- // Close the compose window - let's try again with 3 attachments.
- cw.e("attachmentBucket").removeEventListener(kAttachmentsAdded, listener);
- close_compose_window(cw);
-
- attachmentUrls = [
- "http://www.example.com/1",
- "http://www.example.com/2",
- "http://www.example.com/3",
- ];
-
- // Open the compose window and attach the files, and ensure that we saw
- // the attachments-added event
- cw = open_compose_new_mail(mc);
- cw.e("attachmentBucket").addEventListener(kAttachmentsAdded, listener);
-
- add_attachments(cw, attachmentUrls, null, false);
- assert_equals(2, eventCount);
-
- // Make sure that we got the right subjects back
- subjects = lastEvent.detail;
- assert_true(subjects instanceof Ci.nsIMutableArray);
- assert_equals(3, subjects.length);
-
- for (let attachment of fixIterator(subjects, Ci.nsIMsgAttachment)) {
- assert_true(attachmentUrls.includes(attachment.url));
- }
-
- // Make sure we don't fire the event again if we try to attach the same
- // files.
- add_attachments(cw, attachmentUrls, null, false);
- assert_equals(2, eventCount);
-
- cw.e("attachmentBucket").removeEventListener(kAttachmentsAdded, listener);
- close_compose_window(cw);
-}
-
-/**
- * Test that the attachments-removed event is fired when removing a
- * single file.
- */
-function test_attachments_removed_on_single() {
- // Prepare to listen for attachments-removed
- let eventCount = 0;
- let lastEvent;
- let listener = function(event) {
- eventCount++;
- lastEvent = event;
- };
-
- // Open up the compose window, attach a file...
- let cw = open_compose_new_mail(mc);
- cw.e("attachmentBucket").addEventListener(kAttachmentsRemoved, listener);
-
- add_attachments(cw, "http://www.example.com/1");
-
- // Now select that attachment and delete it
- select_attachments(cw, 0);
- // We need to hold a reference to removedAttachment here because
- // the delete routine nulls it out from the attachmentitem.
- cw.window.goDoCommand("cmd_delete");
- // Make sure we saw the event
- assert_equals(1, eventCount);
- // And make sure we were passed the right attachment item as the
- // subject.
- let subjects = lastEvent.detail;
- assert_true(subjects instanceof Ci.nsIMutableArray);
- assert_equals(1, subjects.length);
- assert_equals(
- subjects.queryElementAt(0, Ci.nsIMsgAttachment).url,
- "http://www.example.com/1"
- );
-
- // Ok, let's attach it again, and remove it again to ensure that
- // we still see the event.
- add_attachments(cw, "http://www.example.com/2");
- select_attachments(cw, 0);
- cw.window.goDoCommand("cmd_delete");
-
- assert_equals(2, eventCount);
- subjects = lastEvent.detail;
- assert_true(subjects instanceof Ci.nsIMutableArray);
- assert_equals(1, subjects.length);
- assert_equals(
- subjects.queryElementAt(0, Ci.nsIMsgAttachment).url,
- "http://www.example.com/2"
- );
-
- cw.e("attachmentBucket").removeEventListener(kAttachmentsRemoved, listener);
- close_compose_window(cw);
-}
-
-/**
- * Test that the attachments-removed event is fired when removing multiple
- * files all at once.
- */
-function test_attachments_removed_on_multiple() {
- // Prepare to listen for attachments-removed
- let eventCount = 0;
- let lastEvent;
- let listener = function(event) {
- eventCount++;
- lastEvent = event;
- };
-
- // Open up the compose window and attach some files...
- let cw = open_compose_new_mail(mc);
- cw.e("attachmentBucket").addEventListener(kAttachmentsRemoved, listener);
-
- add_attachments(cw, [
- "http://www.example.com/1",
- "http://www.example.com/2",
- "http://www.example.com/3",
- ]);
-
- // Select all three attachments, and remove them.
- let removedAttachmentItems = select_attachments(cw, 0, 2);
-
- let removedAttachmentUrls = removedAttachmentItems.map(
- aAttachment => aAttachment.attachment.url
- );
-
- cw.window.goDoCommand("cmd_delete");
-
- // We should have seen the attachments-removed event exactly once.
- assert_equals(1, eventCount);
-
- // Now let's make sure we got passed back the right attachment items
- // as the event subject
- let subjects = lastEvent.detail;
- assert_true(subjects instanceof Ci.nsIMutableArray);
- assert_equals(3, subjects.length);
-
- for (let attachment of fixIterator(subjects, Ci.nsIMsgAttachment)) {
- assert_true(removedAttachmentUrls.includes(attachment.url));
- }
-
- // Ok, let's attach and remove some again to ensure that we still see the event.
- add_attachments(cw, ["http://www.example.com/1", "http://www.example.com/2"]);
-
- select_attachments(cw, 0, 1);
- cw.window.goDoCommand("cmd_delete");
- assert_equals(2, eventCount);
-
- cw.e("attachmentBucket").removeEventListener(kAttachmentsRemoved, listener);
- close_compose_window(cw);
-}
-
-/**
- * Test that we don't see the attachments-removed event if no attachments
- * are selected when hitting "Delete"
- */
-function test_no_attachments_removed_on_none() {
- // Prepare to listen for attachments-removed
- let eventCount = 0;
- let listener = function(event) {
- eventCount++;
- };
-
- // Open the compose window and add some attachments.
- let cw = open_compose_new_mail(mc);
- cw.e("attachmentBucket").addEventListener(kAttachmentsRemoved, listener);
-
- add_attachments(cw, [
- "http://www.example.com/1",
- "http://www.example.com/2",
- "http://www.example.com/3",
- ]);
-
- // Choose no attachments
- cw.e("attachmentBucket").clearSelection();
- // Run the delete command
- cw.window.goDoCommand("cmd_delete");
- // Make sure we didn't see the attachments_removed event.
- assert_equals(0, eventCount);
- cw.e("attachmentBucket").removeEventListener(kAttachmentsRemoved, listener);
-
- close_compose_window(cw);
-}
-
-/**
- * Test that we see the attachment-renamed event when an attachments
- * name is changed.
- */
-function test_attachment_renamed() {
- // Here's what we'll rename some files to.
- const kRenameTo1 = "Renamed-1";
- const kRenameTo2 = "Renamed-2";
- const kRenameTo3 = "Renamed-3";
-
- // Prepare to listen for attachment-renamed
- let eventCount = 0;
- let lastEvent;
- let listener = function(event) {
- eventCount++;
- lastEvent = event;
- };
-
- // Renaming a file brings up a Prompt, so we'll mock the Prompt Service
- gMockPromptService.reset();
- gMockPromptService.register();
- // The inoutValue is used to set the attachment name
- gMockPromptService.inoutValue = kRenameTo1;
- gMockPromptService.returnValue = true;
-
- // Open up the compose window, attach some files, choose the first
- // attachment, and choose to rename it.
- let cw = open_compose_new_mail(mc);
- cw.e("attachmentBucket").addEventListener(kAttachmentRenamed, listener);
-
- add_attachments(cw, [
- "http://www.example.com/1",
- "http://www.example.com/2",
- "http://www.example.com/3",
- ]);
-
- select_attachments(cw, 0);
- cw.window.goDoCommand("cmd_renameAttachment");
-
- // Ensure that we saw the attachment-renamed event
- assert_equals(1, eventCount);
- // Ensure that the event mentions the right attachment
- let renamedAttachment1 = lastEvent.target.attachment;
- let originalName1 = lastEvent.detail;
- assert_true(renamedAttachment1 instanceof Ci.nsIMsgAttachment);
- assert_equals(kRenameTo1, renamedAttachment1.name);
- assert_true(renamedAttachment1.url.includes("http://www.example.com/1"));
- assert_equals("www.example.com/1", originalName1);
-
- // Ok, let's try renaming the same attachment.
- gMockPromptService.reset();
- gMockPromptService.inoutValue = kRenameTo2;
- gMockPromptService.returnValue = true;
-
- select_attachments(cw, 0);
- cw.window.goDoCommand("cmd_renameAttachment");
-
- assert_equals(2, eventCount);
- let renamedAttachment2 = lastEvent.target.attachment;
- let originalName2 = lastEvent.detail;
- assert_true(renamedAttachment2 instanceof Ci.nsIMsgAttachment);
- assert_equals(kRenameTo2, renamedAttachment2.name);
- assert_true(renamedAttachment2.url.includes("http://www.example.com/1"));
- assert_equals(kRenameTo1, originalName2);
-
- // Ok, let's rename another attachment
- gMockPromptService.reset();
- gMockPromptService.inoutValue = kRenameTo3;
- gMockPromptService.returnValue = true;
-
- // We'll select the second attachment this time.
- select_attachments(cw, 1);
- cw.window.goDoCommand("cmd_renameAttachment");
-
- // Ensure we saw the attachment-renamed event
- assert_equals(3, eventCount);
- // Ensure that the event mentions the right attachment
- let renamedAttachment3 = lastEvent.target.attachment;
- let originalName3 = lastEvent.detail;
- assert_true(renamedAttachment3 instanceof Ci.nsIMsgAttachment);
- assert_equals(kRenameTo3, renamedAttachment3.name);
- assert_true(renamedAttachment3.url.includes("http://www.example.com/2"));
- assert_equals("www.example.com/2", originalName3);
-
- // Unregister the Mock Prompt service, and remove our observer.
- cw.e("attachmentBucket").removeEventListener(kAttachmentRenamed, listener);
-
- close_compose_window(cw);
- gMockPromptService.unregister();
-}
-
-/**
- * Test that the attachment-renamed event is not fired if we set the
- * filename to be blank.
- */
-function test_no_attachment_renamed_on_blank() {
- // Prepare to listen for attachment-renamed
- let eventCount = 0;
- let listener = function(event) {
- eventCount++;
- };
-
- // Register the Mock Prompt Service to return the empty string when
- // prompted.
- gMockPromptService.reset();
- gMockPromptService.register();
- gMockPromptService.inoutValue = "";
- gMockPromptService.returnValue = true;
-
- // Open the compose window, attach some files, select one, and chooes to
- // rename it.
- let cw = open_compose_new_mail(mc);
- cw.e("attachmentBucket").addEventListener(kAttachmentRenamed, listener);
-
- add_attachments(cw, [
- "http://www.example.com/1",
- "http://www.example.com/2",
- "http://www.example.com/3",
- ]);
-
- select_attachments(cw, 0);
- cw.window.goDoCommand("cmd_renameAttachment");
-
- // Ensure that we didn't see the attachment-renamed event.
- assert_equals(0, eventCount);
- cw.e("attachmentBucket").removeEventListener(kAttachmentRenamed, listener);
- close_compose_window(cw);
- gMockPromptService.unregister();
-}
deleted file mode 100644
--- a/mail/test/mozmill/attachment/test-attachment-in-plain-msg.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-var os = ChromeUtils.import("chrome://mozmill/content/stdlib/os.jsm");
-
-var { wait_for_element_visible } = ChromeUtils.import(
- "resource://testing-common/mozmill/DOMHelpers.jsm"
-);
-var {
- assert_equals,
- assert_false,
- assert_true,
- open_message_from_file,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { close_window } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-/**
- * Bug 1358565
- * Check that a non-empty image is shown as attachment and is detected as non-empty
- * when message is viewed as plain text.
- */
-async function test_attachment_not_empty() {
- Services.prefs.setBoolPref("mailnews.display.prefer_plaintext", true);
-
- let thisFilePath = os.getFileForPath(__file__);
- let file = os.getFileForPath(os.abspath("./bug1358565.eml", thisFilePath));
-
- let msgc = open_message_from_file(file);
-
- wait_for_element_visible(msgc, "attachmentToggle");
- msgc.click(msgc.eid("attachmentToggle"));
-
- wait_for_element_visible(msgc, "attachmentList");
- assert_equals(msgc.e("attachmentList").itemCount, 1);
-
- let attachmentElem = msgc.e("attachmentList").getItemAtIndex(0);
- assert_equals(attachmentElem.attachment.contentType, "image/jpeg");
- assert_equals(attachmentElem.attachment.name, "bug.png");
- assert_true(attachmentElem.attachment.hasFile);
- assert_false(
- await attachmentElem.attachment.isEmpty(),
- "Attachment incorrectly determined empty"
- );
-
- close_window(msgc);
-
- Services.prefs.clearUserPref("mailnews.display.prefer_plaintext");
-}
deleted file mode 100644
--- a/mail/test/mozmill/attachment/test-attachment-menus.js
+++ /dev/null
@@ -1,535 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-var folder;
-var messenger;
-var epsilon;
-
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-var os = ChromeUtils.import("chrome://mozmill/content/stdlib/os.jsm");
-var controller = ChromeUtils.import(
- "chrome://mozmill/content/modules/controller.jsm"
-);
-
-var {
- create_body_part,
- create_deleted_attachment,
- create_detached_attachment,
- create_enclosure_attachment,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/AttachmentHelpers.jsm"
-);
-var {
- add_message_to_folder,
- be_in_folder,
- close_popup,
- create_folder,
- create_message,
- mc,
- select_click_row,
- wait_for_popup_to_open,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var textAttachment =
- "Can't make the frug contest, Helen; stomach's upset. I'll fix you, " +
- "Ubik! Ubik drops you back in the thick of things fast. Taken as " +
- "directed, Ubik speeds relief to head and stomach. Remember: Ubik is " +
- "only seconds away. Avoid prolonged use.";
-
-var detachedName = "./attachment.txt";
-var missingName = "./nonexistent.txt";
-var deletedName = "deleted.txt";
-
-// create some messages that have various types of attachments
-var messages = [
- {
- name: "regular_attachment",
- attachments: [{ body: textAttachment, filename: "ubik.txt", format: "" }],
- menuStates: [{ open: true, save: true, detach: true, delete_: true }],
- allMenuStates: { open: true, save: true, detach: true, delete_: true },
- },
- {
- name: "detached_attachment",
- bodyPart: null,
- menuStates: [{ open: true, save: true, detach: false, delete_: false }],
- allMenuStates: { open: true, save: true, detach: false, delete_: false },
- },
- {
- name: "detached_attachment_with_missing_file",
- bodyPart: null,
- menuStates: [{ open: false, save: false, detach: false, delete_: false }],
- allMenuStates: { open: false, save: false, detach: false, delete_: false },
- },
- {
- name: "deleted_attachment",
- bodyPart: null,
- menuStates: [{ open: false, save: false, detach: false, delete_: false }],
- allMenuStates: { open: false, save: false, detach: false, delete_: false },
- },
- {
- name: "multiple_attachments",
- attachments: [
- { body: textAttachment, filename: "ubik.txt", format: "" },
- { body: textAttachment, filename: "ubik2.txt", format: "" },
- ],
- menuStates: [
- { open: true, save: true, detach: true, delete_: true },
- { open: true, save: true, detach: true, delete_: true },
- ],
- allMenuStates: { open: true, save: true, detach: true, delete_: true },
- },
- {
- name: "multiple_attachments_one_detached",
- bodyPart: null,
- attachments: [{ body: textAttachment, filename: "ubik.txt", format: "" }],
- menuStates: [
- { open: true, save: true, detach: false, delete_: false },
- { open: true, save: true, detach: true, delete_: true },
- ],
- allMenuStates: { open: true, save: true, detach: true, delete_: true },
- },
- {
- name: "multiple_attachments_one_detached_with_missing_file",
- bodyPart: null,
- attachments: [{ body: textAttachment, filename: "ubik.txt", format: "" }],
- menuStates: [
- { open: false, save: false, detach: false, delete_: false },
- { open: true, save: true, detach: true, delete_: true },
- ],
- allMenuStates: { open: true, save: true, detach: true, delete_: true },
- },
- {
- name: "multiple_attachments_one_deleted",
- bodyPart: null,
- attachments: [{ body: textAttachment, filename: "ubik.txt", format: "" }],
- menuStates: [
- { open: false, save: false, detach: false, delete_: false },
- { open: true, save: true, detach: true, delete_: true },
- ],
- allMenuStates: { open: true, save: true, detach: true, delete_: true },
- },
- {
- name: "multiple_attachments_all_detached",
- bodyPart: null,
- menuStates: [
- { open: true, save: true, detach: false, delete_: false },
- { open: true, save: true, detach: false, delete_: false },
- ],
- allMenuStates: { open: true, save: true, detach: false, delete_: false },
- },
- {
- name: "multiple_attachments_all_detached_with_missing_files",
- bodyPart: null,
- menuStates: [
- { open: false, save: false, detach: false, delete_: false },
- { open: false, save: false, detach: false, delete_: false },
- ],
- allMenuStates: { open: false, save: false, detach: false, delete_: false },
- },
- {
- name: "multiple_attachments_all_deleted",
- bodyPart: null,
- menuStates: [
- { open: false, save: false, detach: false, delete_: false },
- { open: false, save: false, detach: false, delete_: false },
- ],
- allMenuStates: { open: false, save: false, detach: false, delete_: false },
- },
- {
- name: "link_enclosure_valid",
- bodyPart: null,
- menuStates: [{ open: true, save: true, detach: false, delete_: false }],
- allMenuStates: { open: true, save: true, detach: false, delete_: false },
- },
- {
- name: "link_enclosure_invalid",
- bodyPart: null,
- menuStates: [{ open: false, save: false, detach: false, delete_: false }],
- allMenuStates: { open: false, save: false, detach: false, delete_: false },
- },
- {
- name: "link_multiple_enclosures",
- bodyPart: null,
- menuStates: [
- { open: true, save: true, detach: false, delete_: false },
- { open: true, save: true, detach: false, delete_: false },
- ],
- allMenuStates: { open: true, save: true, detach: false, delete_: false },
- },
- {
- name: "link_multiple_enclosures_one_invalid",
- bodyPart: null,
- menuStates: [
- { open: true, save: true, detach: false, delete_: false },
- { open: false, save: false, detach: false, delete_: false },
- ],
- allMenuStates: { open: true, save: true, detach: false, delete_: false },
- },
- {
- name: "link_multiple_enclosures_all_invalid",
- bodyPart: null,
- menuStates: [
- { open: false, save: false, detach: false, delete_: false },
- { open: false, save: false, detach: false, delete_: false },
- ],
- allMenuStates: { open: false, save: false, detach: false, delete_: false },
- },
-];
-
-function setupModule(module) {
- messenger = Cc["@mozilla.org/messenger;1"].createInstance(Ci.nsIMessenger);
-
- /* Today's gory details (thanks to Jonathan Protzenko): libmime somehow
- * counts the trailing newline for an attachment MIME part. Most of the time,
- * assuming attachment has N bytes (no matter what's inside, newlines or
- * not), libmime will return N + 1 bytes. On Linux and Mac, this always
- * holds. However, on Windows, if the attachment is not encoded (that is, is
- * inline text), libmime will return N + 2 bytes.
- */
- epsilon = "@mozilla.org/windows-registry-key;1" in Cc ? 2 : 1;
-
- // set up our detached/deleted attachments
- var thisFilePath = os.getFileForPath(__file__);
-
- var detachedFile = os.getFileForPath(os.abspath(detachedName, thisFilePath));
- var detached = create_body_part("Here is a file", [
- create_detached_attachment(detachedFile, "text/plain"),
- ]);
- var multiple_detached = create_body_part("Here are some files", [
- create_detached_attachment(detachedFile, "text/plain"),
- create_detached_attachment(detachedFile, "text/plain"),
- ]);
-
- var missingFile = os.getFileForPath(os.abspath(missingName, thisFilePath));
- var missing = create_body_part(
- "Here is a file (but you deleted the external file, you silly oaf!)",
- [create_detached_attachment(missingFile, "text/plain")]
- );
- var multiple_missing = create_body_part(
- "Here are some files (but you deleted the external files, you silly oaf!)",
- [
- create_detached_attachment(missingFile, "text/plain"),
- create_detached_attachment(missingFile, "text/plain"),
- ]
- );
-
- var deleted = create_body_part("Here is a file that you deleted", [
- create_deleted_attachment(deletedName, "text/plain"),
- ]);
- var multiple_deleted = create_body_part(
- "Here are some files that you deleted",
- [
- create_deleted_attachment(deletedName, "text/plain"),
- create_deleted_attachment(deletedName, "text/plain"),
- ]
- );
-
- var enclosure_valid_url = create_body_part("My blog has the best enclosure", [
- create_enclosure_attachment(
- "purr.mp3",
- "audio/mpeg",
- "http://example.com",
- 12345678
- ),
- ]);
- var enclosure_invalid_url = create_body_part(
- "My blog has the best enclosure with a dead link",
- [
- create_enclosure_attachment(
- "meow.mp3",
- "audio/mpeg",
- "http://example.com/invalid"
- ),
- ]
- );
- var multiple_enclosures = create_body_part(
- "My blog has the best 2 cat sound enclosures",
- [
- create_enclosure_attachment(
- "purr.mp3",
- "audio/mpeg",
- "http://example.com",
- 1234567
- ),
- create_enclosure_attachment(
- "meow.mp3",
- "audio/mpeg",
- "http://example.com",
- 987654321
- ),
- ]
- );
- var multiple_enclosures_one_link_invalid = create_body_part(
- "My blog has the best 2 cat sound enclosures but one is invalid",
- [
- create_enclosure_attachment(
- "purr.mp3",
- "audio/mpeg",
- "http://example.com",
- 1234567
- ),
- create_enclosure_attachment(
- "meow.mp3",
- "audio/mpeg",
- "http://example.com/invalid"
- ),
- ]
- );
- var multiple_enclosures_all_links_invalid = create_body_part(
- "My blog has 2 enclosures with 2 bad links",
- [
- create_enclosure_attachment(
- "purr.mp3",
- "audio/mpeg",
- "http://example.com/invalid"
- ),
- create_enclosure_attachment(
- "meow.mp3",
- "audio/mpeg",
- "http://example.com/invalid"
- ),
- ]
- );
-
- folder = create_folder("AttachmentMenusA");
- for (let i = 0; i < messages.length; i++) {
- // First, add any missing info to the message object.
- switch (messages[i].name) {
- case "detached_attachment":
- case "multiple_attachments_one_detached":
- messages[i].bodyPart = detached;
- break;
- case "multiple_attachments_all_detached":
- messages[i].bodyPart = multiple_detached;
- break;
- case "detached_attachment_with_missing_file":
- case "multiple_attachments_one_detached_with_missing_file":
- messages[i].bodyPart = missing;
- break;
- case "multiple_attachments_all_detached_with_missing_files":
- messages[i].bodyPart = multiple_missing;
- break;
- case "deleted_attachment":
- case "multiple_attachments_one_deleted":
- messages[i].bodyPart = deleted;
- break;
- case "multiple_attachments_all_deleted":
- messages[i].bodyPart = multiple_deleted;
- break;
- case "link_enclosure_valid":
- messages[i].bodyPart = enclosure_valid_url;
- break;
- case "link_enclosure_invalid":
- messages[i].bodyPart = enclosure_invalid_url;
- break;
- case "link_multiple_enclosures":
- messages[i].bodyPart = multiple_enclosures;
- break;
- case "link_multiple_enclosures_one_invalid":
- messages[i].bodyPart = multiple_enclosures_one_link_invalid;
- break;
- case "link_multiple_enclosures_all_invalid":
- messages[i].bodyPart = multiple_enclosures_all_links_invalid;
- break;
- }
-
- add_message_to_folder(folder, create_message(messages[i]));
- }
-}
-
-/**
- * Ensure that the specified element is visible/hidden
- *
- * @param id the id of the element to check
- * @param visible true if the element should be visible, false otherwise
- */
-function assert_shown(id, visible) {
- if (mc.e(id).hidden == visible) {
- throw new Error(
- '"' + id + '" should be ' + (visible ? "visible" : "hidden")
- );
- }
-}
-
-/**
- * Ensure that the specified element is enabled/disabled
- *
- * @param id the id of the element to check
- * @param enabled true if the element should be enabled, false otherwise
- */
-function assert_enabled(id, enabled) {
- if (mc.e(id).disabled == enabled) {
- throw new Error(
- '"' + id + '" should be ' + (enabled ? "enabled" : "disabled")
- );
- }
-}
-
-/**
- * Check that the menu states in the "save" toolbar button are correct.
- *
- * @param expected a dictionary containing the expected states
- */
-function check_toolbar_menu_states_single(expected) {
- assert_shown("attachmentSaveAllSingle", true);
- assert_shown("attachmentSaveAllMultiple", false);
-
- if (expected.save === false) {
- assert_enabled("attachmentSaveAllSingle", false);
- } else {
- assert_enabled("attachmentSaveAllSingle", true);
- mc.click(
- new elementslib.Elem(
- mc
- .e("attachmentSaveAllSingle")
- .querySelector(".toolbarbutton-menubutton-dropmarker")
- )
- );
- wait_for_popup_to_open(mc.e("attachmentSaveAllSingleMenu"));
-
- try {
- assert_enabled("button-openAttachment", expected.open);
- assert_enabled("button-saveAttachment", expected.save);
- assert_enabled("button-detachAttachment", expected.detach);
- assert_enabled("button-deleteAttachment", expected.delete_);
- } finally {
- close_popup(mc, mc.eid("attachmentSaveAllSingleMenu"));
- }
- }
-}
-
-/**
- * Check that the menu states in the "save all" toolbar button are correct.
- *
- * @param expected a dictionary containing the expected states
- */
-function check_toolbar_menu_states_multiple(expected) {
- assert_shown("attachmentSaveAllSingle", false);
- assert_shown("attachmentSaveAllMultiple", true);
-
- if (expected.save === false) {
- assert_enabled("attachmentSaveAllMultiple", false);
- } else {
- assert_enabled("attachmentSaveAllMultiple", true);
- mc.click(
- new elementslib.Elem(
- mc
- .e("attachmentSaveAllMultiple")
- .querySelector(".toolbarbutton-menubutton-dropmarker")
- )
- );
- wait_for_popup_to_open(mc.e("attachmentSaveAllMultipleMenu"));
-
- try {
- assert_enabled("button-openAllAttachments", expected.open);
- assert_enabled("button-saveAllAttachments", expected.save);
- assert_enabled("button-detachAllAttachments", expected.detach);
- assert_enabled("button-deleteAllAttachments", expected.delete_);
- } finally {
- close_popup(mc, mc.eid("attachmentSaveAllMultipleMenu"));
- }
- }
-}
-
-/**
- * Check that the menu states in the single item context menu are correct
- *
- * @param expected a dictionary containing the expected states
- */
-function check_menu_states_single(index, expected) {
- let attachmentList = mc.e("attachmentList");
- let node = attachmentList.getItemAtIndex(index);
-
- attachmentList.selectItem(node);
- let menu = mc.getMenu("#attachmentItemContext");
- menu.open(new elib.Elem(node));
- wait_for_popup_to_open(mc.e("attachmentItemContext"));
-
- try {
- assert_shown("context-openAttachment", true);
- assert_shown("context-saveAttachment", true);
- assert_shown("context-menu-separator", true);
- assert_shown("context-detachAttachment", true);
- assert_shown("context-deleteAttachment", true);
-
- assert_enabled("context-openAttachment", expected.open);
- assert_enabled("context-saveAttachment", expected.save);
- assert_enabled("context-detachAttachment", expected.detach);
- assert_enabled("context-deleteAttachment", expected.delete_);
- } finally {
- menu.close();
- }
-}
-
-/**
- * Check that the menu states in the all items context menu are correct
- *
- * @param expected a dictionary containing the expected states
- */
-function check_menu_states_all(expected) {
- // Using a rightClick here is unsafe, because we need to hit the empty area
- // beside the attachment items and that seems to be different per platform.
- // Using DOM methods to open the popup works fine.
- mc.e("attachmentListContext").openPopup(mc.e("attachmentList"));
- wait_for_popup_to_open(mc.e("attachmentListContext"));
-
- try {
- assert_shown("context-openAllAttachments", true);
- assert_shown("context-saveAllAttachments", true);
- assert_shown("context-menu-separator-all", true);
- assert_shown("context-detachAllAttachments", true);
- assert_shown("context-deleteAllAttachments", true);
-
- assert_enabled("context-openAllAttachments", expected.open);
- assert_enabled("context-saveAllAttachments", expected.save);
- assert_enabled("context-detachAllAttachments", expected.detach);
- assert_enabled("context-deleteAllAttachments", expected.delete_);
- } finally {
- close_popup(mc, mc.eid("attachmentListContext"));
- }
-}
-
-function help_test_attachment_menus(index) {
- be_in_folder(folder);
- select_click_row(index);
- let expectedStates = messages[index].menuStates;
-
- mc.window.toggleAttachmentList(true);
-
- for (let attachment of mc.window.currentAttachments) {
- // Ensure all attachments are resolved; other than external they already
- // should be.
- attachment.isEmpty();
- }
-
- // Test funcs are generated in the global scope, and there isn't a way to
- // do this async (like within an async add_task in xpcshell) so await can
- // force serial execution of each test. Wait here for the fetch() to complete.
- controller.sleep(1000);
-
- if (expectedStates.length == 1) {
- check_toolbar_menu_states_single(messages[index].allMenuStates);
- } else {
- check_toolbar_menu_states_multiple(messages[index].allMenuStates);
- }
-
- check_menu_states_all(messages[index].allMenuStates);
- for (let i = 0; i < expectedStates.length; i++) {
- check_menu_states_single(i, expectedStates[i]);
- }
-}
-
-// Generate a test for each message in |messages|.
-for (let [i, message] of messages.entries()) {
- let index = i; // make a copy to avoid passing a reference to i
- this["test_" + message.name] = function() {
- help_test_attachment_menus(index);
- };
-}
deleted file mode 100644
--- a/mail/test/mozmill/attachment/test-attachment-size.js
+++ /dev/null
@@ -1,430 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-var folder;
-var messenger;
-var epsilon;
-
-var os = ChromeUtils.import("chrome://mozmill/content/stdlib/os.jsm");
-var controller = ChromeUtils.import(
- "chrome://mozmill/content/modules/controller.jsm"
-);
-
-var {
- create_body_part,
- create_deleted_attachment,
- create_detached_attachment,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/AttachmentHelpers.jsm"
-);
-var {
- add_message_to_folder,
- be_in_folder,
- create_folder,
- create_message,
- mc,
- msgGen,
- select_click_row,
- SyntheticPartLeaf,
- SyntheticPartMultiMixed,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var textAttachment =
- "Can't make the frug contest, Helen; stomach's upset. I'll fix you, " +
- "Ubik! Ubik drops you back in the thick of things fast. Taken as " +
- "directed, Ubik speeds relief to head and stomach. Remember: Ubik is " +
- "only seconds away. Avoid prolonged use.";
-
-var binaryAttachment = textAttachment;
-
-var imageAttachment =
- "iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAABHNCSVQICAgIfAhkiAAAAAlwS" +
- "FlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAA" +
- "A5SURBVCiRY/z//z8DKYCJJNXkaGBgYGD4D8NQ5zUgiTVAxeBqSLaBkVRPM0KtIhrQ3km0jwe" +
- "SNQAAlmAY+71EgFoAAAAASUVORK5CYII=";
-var imageSize = 188;
-
-var vcardAttachment =
- "YmVnaW46dmNhcmQNCmZuOkppbSBCb2INCm46Qm9iO0ppbQ0KZW1haWw7aW50ZXJuZXQ6Zm9v" +
- "QGJhci5jb20NCnZlcnNpb246Mi4xDQplbmQ6dmNhcmQNCg0K";
-
-var detachedName = "./attachment.txt";
-var missingName = "./nonexistent.txt";
-var deletedName = "deleted.txt";
-
-// create some messages that have various types of attachments
-var messages = [
- {
- name: "text_attachment",
- attachments: [{ body: textAttachment, filename: "ubik.txt", format: "" }],
- attachmentSizes: [textAttachment.length],
- attachmentTotalSize: { size: textAttachment.length, exact: true },
- },
- {
- name: "binary_attachment",
- attachments: [
- {
- body: binaryAttachment,
- contentType: "application/x-ubik",
- filename: "ubik",
- format: "",
- },
- ],
- attachmentSizes: [binaryAttachment.length],
- attachmentTotalSize: { size: binaryAttachment.length, exact: true },
- },
- {
- name: "image_attachment",
- attachments: [
- {
- body: imageAttachment,
- contentType: "image/png",
- filename: "lines.png",
- encoding: "base64",
- format: "",
- },
- ],
- attachmentSizes: [imageSize],
- attachmentTotalSize: { size: imageSize, exact: true },
- },
- {
- name: "detached_attachment",
- bodyPart: null,
- // Sizes filled in on message creation.
- attachmentSizes: [null],
- attachmentTotalSize: { size: 0, exact: true },
- },
- {
- name: "detached_attachment_with_missing_file",
- bodyPart: null,
- attachmentSizes: [-1],
- attachmentTotalSize: { size: 0, exact: false },
- },
- {
- name: "deleted_attachment",
- bodyPart: null,
- attachmentSizes: [-1],
- attachmentTotalSize: { size: 0, exact: true },
- },
- {
- name: "multiple_attachments",
- attachments: [
- { body: textAttachment, filename: "ubik.txt", format: "" },
- {
- body: binaryAttachment,
- contentType: "application/x-ubik",
- filename: "ubik",
- format: "",
- },
- ],
- attachmentSizes: [textAttachment.length, binaryAttachment.length],
- attachmentTotalSize: {
- size: textAttachment.length + binaryAttachment.length,
- exact: true,
- },
- },
- // vCards should be ignored in the attachment list; make sure we do so
- // properly.
- {
- name: "multiple_attachments_one_vcard",
- attachments: [
- { body: textAttachment, filename: "ubik.txt", format: "" },
- {
- body: vcardAttachment,
- contentType: "text/x-vcard",
- filename: "ubik.vcf",
- encoding: "base64",
- format: "",
- },
- ],
- attachmentSizes: [textAttachment.length],
- attachmentTotalSize: { size: textAttachment.length, exact: true },
- },
- {
- name: "multiple_attachments_one_detached",
- bodyPart: null,
- attachments: [{ body: textAttachment, filename: "ubik.txt", format: "" }],
- attachmentSizes: [null, textAttachment.length],
- attachmentTotalSize: { size: textAttachment.length, exact: true },
- },
- {
- name: "multiple_attachments_one_detached_with_missing_file",
- bodyPart: null,
- attachments: [{ body: textAttachment, filename: "ubik.txt", format: "" }],
- attachmentSizes: [-1, textAttachment.length],
- attachmentTotalSize: { size: textAttachment.length, exact: false },
- },
- {
- name: "multiple_attachments_one_deleted",
- bodyPart: null,
- attachments: [{ body: textAttachment, filename: "ubik.txt", format: "" }],
- attachmentSizes: [-1, textAttachment.length],
- attachmentTotalSize: { size: textAttachment.length, exact: true },
- },
- // this is an attached message that itself has an attachment
- {
- name: "attached_message_with_attachment",
- bodyPart: null,
- attachmentSizes: [-1, textAttachment.length],
- attachmentTotalSize: { size: 0, exact: true },
- },
-];
-
-function setupModule(module) {
- messenger = Cc["@mozilla.org/messenger;1"].createInstance(Ci.nsIMessenger);
-
- /* Today's gory details (thanks to Jonathan Protzenko): libmime somehow
- * counts the trailing newline for an attachment MIME part. Most of the time,
- * assuming attachment has N bytes (no matter what's inside, newlines or
- * not), libmime will return N + 1 bytes. On Linux and Mac, this always
- * holds. However, on Windows, if the attachment is not encoded (that is, is
- * inline text), libmime will return N + 2 bytes.
- */
- epsilon = "@mozilla.org/windows-registry-key;1" in Cc ? 4 : 2;
-
- // set up our detached/deleted attachments
- var thisFilePath = os.getFileForPath(__file__);
-
- var detachedFile = os.getFileForPath(os.abspath(detachedName, thisFilePath));
- var detached = create_body_part("Here is a file", [
- create_detached_attachment(detachedFile, "text/plain"),
- ]);
-
- var missingFile = os.getFileForPath(os.abspath(missingName, thisFilePath));
- var missing = create_body_part(
- "Here is a file (but you deleted the external file, you silly oaf!)",
- [create_detached_attachment(missingFile, "text/plain")]
- );
-
- var deleted = create_body_part("Here is a file that you deleted", [
- create_deleted_attachment(deletedName, "text/plain"),
- ]);
-
- var attachedMessage = msgGen.makeMessage({
- body: { body: textAttachment },
- attachments: [{ body: textAttachment, filename: "ubik.txt", format: "" }],
- });
-
- /* Much like the above comment, libmime counts bytes differently on Windows,
- * where it counts newlines (\r\n) as 2 bytes. Mac and Linux treats them as
- * 1 byte.
- */
- var attachedMessageLength;
- if (epsilon == 4) {
- // Windows
- attachedMessageLength = attachedMessage.toMessageString().length;
- } else {
- // Mac/Linux
- attachedMessageLength = attachedMessage
- .toMessageString()
- .replace(/\r\n/g, "\n").length;
- }
-
- folder = create_folder("AttachmentSizeA");
- for (let i = 0; i < messages.length; i++) {
- // First, add any missing info to the message object.
- switch (messages[i].name) {
- case "detached_attachment":
- case "multiple_attachments_one_detached":
- messages[i].bodyPart = detached;
- messages[i].attachmentSizes[0] = detachedFile.fileSize;
- messages[i].attachmentTotalSize.size += detachedFile.fileSize;
- break;
- case "detached_attachment_with_missing_file":
- case "multiple_attachments_one_detached_with_missing_file":
- messages[i].bodyPart = missing;
- break;
- case "deleted_attachment":
- case "multiple_attachments_one_deleted":
- messages[i].bodyPart = deleted;
- break;
- case "attached_message_with_attachment":
- messages[i].bodyPart = new SyntheticPartMultiMixed([
- new SyntheticPartLeaf("I am text!", { contentType: "text/plain" }),
- attachedMessage,
- ]);
- messages[i].attachmentSizes[0] = attachedMessageLength;
- messages[i].attachmentTotalSize.size += attachedMessageLength;
- break;
- }
-
- add_message_to_folder(folder, create_message(messages[i]));
- }
-}
-
-/**
- * Make sure that the attachment's size is what we expect
- * @param index the attachment's index, starting at 0
- * @param expectedSize the expected size of the attachment, in bytes
- */
-function check_attachment_size(index, expectedSize) {
- let list = mc.e("attachmentList");
- let node = list.querySelectorAll("richlistitem.attachmentItem")[index];
-
- // First, let's check that the attachment size is correct
- let size = node.attachment.size;
- if (Math.abs(size - expectedSize) > epsilon) {
- throw new Error(
- "Reported attachment size (" +
- size +
- ") not within epsilon " +
- "of actual attachment size (" +
- expectedSize +
- ")"
- );
- }
-
- // Next, make sure that the formatted size in the label is correct
- let formattedSize = node.getAttribute("size");
- let expectedFormattedSize = messenger.formatFileSize(size);
- if (formattedSize != expectedFormattedSize) {
- throw new Error(
- "Formatted attachment size (" +
- formattedSize +
- ") does not " +
- "match expected value (" +
- expectedFormattedSize +
- ")"
- );
- }
-}
-
-/**
- * Make sure that the attachment's size is not displayed
- * @param index the attachment's index, starting at 0
- */
-function check_no_attachment_size(index) {
- let list = mc.e("attachmentList");
- let node = list.querySelectorAll("richlistitem.attachmentItem")[index];
-
- if (node.attachment.size != -1) {
- throw new Error(
- "attachmentSize attribute of deleted attachment should be -1!"
- );
- }
-
- // If there's no size, the size attribute is the zero-width space.
- let nodeSize = node.getAttribute("size");
- mc.window.console.log(
- "check_no_attachment_size: node.size->" + nodeSize + "<-"
- );
- if (nodeSize != "\u200b" && nodeSize != "") {
- throw new Error("Attachment size should not be displayed!");
- }
-}
-
-/**
- * Make sure that the total size of all attachments is what we expect.
- * @param count the expected number of attachments
- * @param expectedSize the expected size in bytes of all the attachments
- * @param exact true if the size of all attachments is known, false otherwise
- */
-function check_total_attachment_size(count, expectedSize, exact) {
- let list = mc.e("attachmentList");
- let nodes = list.querySelectorAll("richlistitem.attachmentItem");
- let sizeNode = mc.e("attachmentSize");
-
- if (nodes.length != count) {
- throw new Error(
- "Saw " + nodes.length + " attachments, but expected " + count
- );
- }
-
- let lastPartID;
- let size = 0;
- for (let i = 0; i < nodes.length; i++) {
- let attachment = nodes[i].attachment;
- if (!lastPartID || attachment.partID.indexOf(lastPartID) != 0) {
- lastPartID = attachment.partID;
- let currSize = attachment.size;
- if (currSize > 0 && !isNaN(currSize)) {
- size += Number(currSize);
- }
- }
- }
-
- if (Math.abs(size - expectedSize) > epsilon * count) {
- throw new Error(
- "Reported attachment size (" +
- size +
- ") not within epsilon " +
- "of actual attachment size (" +
- expectedSize +
- ")"
- );
- }
-
- // Next, make sure that the formatted size in the label is correct
- let formattedSize = sizeNode.getAttribute("value");
- let expectedFormattedSize = messenger.formatFileSize(size);
- let messengerBundle = mc.window.document.getElementById("bundle_messenger");
-
- if (!exact) {
- if (size == 0) {
- expectedFormattedSize = messengerBundle.getString(
- "attachmentSizeUnknown"
- );
- } else {
- expectedFormattedSize = messengerBundle.getFormattedString(
- "attachmentSizeAtLeast",
- [expectedFormattedSize]
- );
- }
- }
- if (formattedSize != expectedFormattedSize) {
- throw new Error(
- "Formatted attachment size (" +
- formattedSize +
- ") does not " +
- "match expected value (" +
- expectedFormattedSize +
- ")"
- );
- }
-}
-
-/**
- * Make sure that the individual and total attachment sizes for this message
- * are as expected
- * @param index the index of the message to check in the thread pane
- */
-function help_test_attachment_size(index) {
- be_in_folder(folder);
- select_click_row(index);
- let expectedSizes = messages[index].attachmentSizes;
-
- mc.window.toggleAttachmentList(true);
-
- // Test funcs are generated in the global scope, and there isn't a way to
- // do this async (like within an async add_task in xpcshell) so await can
- // force serial execution of each test. Wait here for the fetch() to complete.
- controller.sleep(2000);
-
- for (let i = 0; i < expectedSizes.length; i++) {
- if (expectedSizes[i] == -1) {
- check_no_attachment_size(i);
- } else {
- check_attachment_size(i, expectedSizes[i]);
- }
- }
-
- let totalSize = messages[index].attachmentTotalSize;
- check_total_attachment_size(
- expectedSizes.length,
- totalSize.size,
- totalSize.exact
- );
-}
-
-// Generate a test for each message in |messages|.
-for (let [i, message] of messages.entries()) {
- let index = i; // make a copy to avoid passing a reference to i
- this["test_" + message.name] = function() {
- help_test_attachment_size(index);
- };
-}
deleted file mode 100644
--- a/mail/test/mozmill/attachment/test-attachment.js
+++ /dev/null
@@ -1,654 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Checks various attachments display correctly
- */
-
-"use strict";
-
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-var EventUtils = ChromeUtils.import(
- "chrome://mozmill/content/stdlib/EventUtils.jsm"
-);
-
-var { close_compose_window, open_compose_with_forward } = ChromeUtils.import(
- "resource://testing-common/mozmill/ComposeHelpers.jsm"
-);
-var {
- add_message_to_folder,
- assert_attachment_list_focused,
- assert_equals,
- assert_message_pane_focused,
- assert_selected_and_displayed,
- assert_true,
- be_in_folder,
- close_popup,
- create_folder,
- create_message,
- mc,
- msgGen,
- plan_to_wait_for_folder_events,
- select_click_row,
- select_none,
- SyntheticPartLeaf,
- SyntheticPartMultiMixed,
- wait_for_folder_events,
- wait_for_message_display_completion,
- wait_for_popup_to_open,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var {
- close_window,
- plan_for_modal_dialog,
- plan_for_new_window,
- wait_for_modal_dialog,
- wait_for_new_window,
-} = ChromeUtils.import("resource://testing-common/mozmill/WindowHelpers.jsm");
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var folder;
-var messages;
-
-var textAttachment =
- "One of these days... people like me will rise up and overthrow you, and " +
- "the end of tyranny by the homeostatic machine will have arrived. The day " +
- "of human values and compassion and simple warmth will return, and when " +
- "that happens someone like myself who has gone through an ordeal and who " +
- "genuinely needs hot coffee to pick him up and keep him functioning when " +
- "he has to function will get the hot coffee whether he happens to have a " +
- "poscred readily available or not.";
-
-var binaryAttachment = textAttachment;
-
-function setupModule(module) {
- folder = create_folder("AttachmentA");
-
- var attachedMessage = msgGen.makeMessage({
- body: { body: "I'm an attached email!" },
- attachments: [
- { body: textAttachment, filename: "inner attachment.txt", format: "" },
- ],
- });
-
- // create some messages that have various types of attachments
- messages = [
- // no attachment
- {},
- // text attachment
- {
- attachments: [{ body: textAttachment, filename: "ubik.txt", format: "" }],
- },
- // binary attachment; filename has 9 "1"s, which should be just within the
- // limit for showing the original name
- {
- attachments: [
- {
- body: binaryAttachment,
- contentType: "application/octet-stream",
- filename: "ubik-111111111.xxyyzz",
- format: "",
- },
- ],
- },
- // multiple attachments
- {
- attachments: [
- { body: textAttachment, filename: "ubik.txt", format: "" },
- {
- body: binaryAttachment,
- contentType: "application/octet-stream",
- filename: "ubik.xxyyzz",
- format: "",
- },
- ],
- },
- // attachment with a long name; the attachment bar should crop this
- {
- attachments: [
- {
- body: textAttachment,
- filename:
- "this-is-a-file-with-an-extremely-long-name-" +
- "that-seems-to-go-on-forever-seriously-you-" +
- "would-not-believe-how-long-this-name-is-it-" +
- "surely-exceeds-the-maximum-filename-length-" +
- "for-most-filesystems.txt",
- format: "",
- },
- ],
- },
- // a message with a text attachment and an email attachment, which in turn
- // has its own text attachment
- {
- bodyPart: new SyntheticPartMultiMixed([
- new SyntheticPartLeaf("I'm a message!"),
- new SyntheticPartLeaf(textAttachment, {
- filename: "outer attachment.txt",
- contentType: "text/plain",
- format: "",
- }),
- attachedMessage,
- ]),
- },
- // evilly-named attachment; spaces should be collapsed and trimmed on the
- // ends
- {
- attachments: [
- {
- body: textAttachment,
- contentType: "application/octet-stream",
- filename: " ubik .txt .evil ",
- sanitizedFilename: "ubik .txt .evil",
- format: "",
- },
- ],
- },
- // another evilly-named attachment; filename has 10 "_"s, which should be
- // just enough to trigger the sanitizer
- {
- attachments: [
- {
- body: textAttachment,
- contentType: "application/octet-stream",
- filename: "ubik.txt__________.evil",
- sanitizedFilename: "ubik.txt_…_.evil",
- format: "",
- },
- ],
- },
- ];
-
- // Add another evilly-named attachment for Windows tests, to ensure that
- // trailing periods are stripped.
- if ("@mozilla.org/windows-registry-key;1" in Cc) {
- messages.push({
- attachments: [
- {
- body: textAttachment,
- contentType: "application/octet-stream",
- filename: "ubik.evil. . . . . . . . . ....",
- sanitizedFilename: "ubik.evil",
- format: "",
- },
- ],
- });
- }
-
- for (let i = 0; i < messages.length; i++) {
- add_message_to_folder(folder, create_message(messages[i]));
- }
-}
-
-/**
- * Set the pref to ensure that the attachments pane starts out (un)expanded
- *
- * @param expand true if the attachment pane should start out expanded,
- * false otherwise
- */
-function ensure_starts_expanded(expand) {
- Services.prefs.setBoolPref(
- "mailnews.attachments.display.start_expanded",
- expand
- );
-}
-
-function test_attachment_view_collapsed() {
- be_in_folder(folder);
-
- select_click_row(0);
- assert_selected_and_displayed(0);
-
- if (!mc.e("attachmentView").collapsed) {
- throw new Error("Attachment pane expanded when it shouldn't be!");
- }
-}
-
-function test_attachment_view_expanded() {
- be_in_folder(folder);
-
- for (let i = 1; i < messages.length; i++) {
- select_click_row(i);
- assert_selected_and_displayed(i);
-
- if (mc.e("attachmentView").collapsed) {
- throw new Error(
- "Attachment pane collapsed (on message #" + i + " when it shouldn't be!"
- );
- }
- }
-}
-
-function test_attachment_name_sanitization() {
- be_in_folder(folder);
-
- let attachmentList = mc.e("attachmentList");
-
- for (let i = 0; i < messages.length; i++) {
- if ("attachments" in messages[i]) {
- select_click_row(i);
- assert_selected_and_displayed(i);
-
- let attachments = messages[i].attachments;
- if (messages[i].attachments.length == 1) {
- assert_equals(
- mc.e("attachmentName").value,
- attachments[0].sanitizedFilename || attachments[0].filename
- );
- }
-
- for (let j = 0; j < attachments.length; j++) {
- assert_equals(
- attachmentList.getItemAtIndex(j).getAttribute("name"),
- attachments[j].sanitizedFilename || attachments[j].filename
- );
- }
- }
- }
-}
-
-function test_long_attachment_name() {
- be_in_folder(folder);
-
- select_click_row(4);
- assert_selected_and_displayed(4);
-
- let messagepaneBox = mc.e("messagepanebox");
- let attachmentBar = mc.e("attachmentBar");
-
- assert_true(
- messagepaneBox.getBoundingClientRect().width >=
- attachmentBar.getBoundingClientRect().width,
- "Attachment bar has expanded off the edge of the window!"
- );
-}
-
-/**
- * Make sure that, when opening attached messages, we only show the attachments
- * "beneath" the attached message (as opposed to all attachments for the root
- * message).
- */
-function test_attached_message_attachments() {
- be_in_folder(folder);
-
- select_click_row(5);
- assert_selected_and_displayed(5);
-
- // Make sure we have the expected number of attachments in the root message:
- // an outer text attachment, an attached email, and an inner text attachment.
- assert_equals(mc.e("attachmentList").itemCount, 3);
-
- // Open the attached email.
- plan_for_new_window("mail:messageWindow");
- mc.e("attachmentList")
- .getItemAtIndex(1)
- .attachment.open();
- let msgc = wait_for_new_window("mail:messageWindow");
- wait_for_message_display_completion(msgc, true);
-
- // Make sure we have the expected number of attachments in the attached
- // message: just an inner text attachment.
- assert_equals(msgc.e("attachmentList").itemCount, 1);
-
- close_window(msgc);
-}
-
-function test_attachment_name_click() {
- be_in_folder(folder);
-
- select_click_row(1);
- assert_selected_and_displayed(1);
-
- let attachmentList = mc.e("attachmentList");
-
- assert_true(
- attachmentList.collapsed,
- "Attachment list should start out collapsed!"
- );
-
- // Ensure the open dialog appears when clicking on the attachment name and
- // that the attachment list doesn't expand.
- plan_for_modal_dialog("unknownContentTypeWindow", function() {});
- mc.click(mc.eid("attachmentName"));
- wait_for_modal_dialog("unknownContentTypeWindow");
- assert_true(
- attachmentList.collapsed,
- "Attachment list should not expand when clicking on attachmentName!"
- );
-}
-
-/**
- * Test that right-clicking on a particular element opens the expected context
- * menu.
- *
- * @param elementId the id of the element to right click on
- * @param contextMenuId the id of the context menu that should appear
- */
-function subtest_attachment_right_click(elementId, contextMenuId) {
- mc.rightClick(mc.eid(elementId));
- wait_for_popup_to_open(mc.e(contextMenuId));
- close_popup(mc, mc.eid(contextMenuId));
-}
-
-function test_attachment_right_click_single() {
- be_in_folder(folder);
-
- select_click_row(1);
- assert_selected_and_displayed(1);
-
- subtest_attachment_right_click("attachmentIcon", "attachmentItemContext");
- subtest_attachment_right_click("attachmentCount", "attachmentItemContext");
- subtest_attachment_right_click("attachmentName", "attachmentItemContext");
- subtest_attachment_right_click("attachmentSize", "attachmentItemContext");
-
- subtest_attachment_right_click(
- "attachmentToggle",
- "attachment-toolbar-context-menu"
- );
- subtest_attachment_right_click(
- "attachmentSaveAllSingle",
- "attachment-toolbar-context-menu"
- );
- subtest_attachment_right_click(
- "attachmentBar",
- "attachment-toolbar-context-menu"
- );
-}
-
-function test_attachment_right_click_multiple() {
- be_in_folder(folder);
-
- select_click_row(3);
- assert_selected_and_displayed(3);
-
- subtest_attachment_right_click("attachmentIcon", "attachmentListContext");
- subtest_attachment_right_click("attachmentCount", "attachmentListContext");
- subtest_attachment_right_click("attachmentSize", "attachmentListContext");
-
- subtest_attachment_right_click(
- "attachmentToggle",
- "attachment-toolbar-context-menu"
- );
- subtest_attachment_right_click(
- "attachmentSaveAllMultiple",
- "attachment-toolbar-context-menu"
- );
- subtest_attachment_right_click(
- "attachmentBar",
- "attachment-toolbar-context-menu"
- );
-}
-
-/**
- * Test that clicking on various elements in the attachment bar toggles the
- * attachment list.
- *
- * @param elementId the id of the element to click
- */
-function subtest_attachment_list_toggle(elementId) {
- let attachmentList = mc.e("attachmentList");
- let element = mc.eid(elementId);
-
- mc.click(element);
- assert_true(
- !attachmentList.collapsed,
- `Attachment list should be expanded after clicking ${elementId}!`
- );
- assert_attachment_list_focused();
-
- mc.click(element);
- assert_true(
- attachmentList.collapsed,
- `Attachment list should be collapsed after clicking ${elementId} again!`
- );
- assert_message_pane_focused();
-}
-
-function test_attachment_list_expansion() {
- be_in_folder(folder);
-
- select_click_row(1);
- assert_selected_and_displayed(1);
-
- assert_true(
- mc.e("attachmentList").collapsed,
- "Attachment list should start out collapsed!"
- );
-
- subtest_attachment_list_toggle("attachmentToggle");
- subtest_attachment_list_toggle("attachmentIcon");
- subtest_attachment_list_toggle("attachmentCount");
- subtest_attachment_list_toggle("attachmentSize");
- subtest_attachment_list_toggle("attachmentBar");
-
- // Ensure that clicking the "Save All" button doesn't expand the attachment
- // list.
- mc.click(
- new elementslib.Elem(
- mc
- .e("attachmentSaveAllSingle")
- .querySelector(".toolbarbutton-menubutton-dropmarker")
- )
- );
- assert_true(
- mc.e("attachmentList").collapsed,
- "Attachment list should be collapsed after clicking save button!"
- );
-}
-
-function test_attachment_list_starts_expanded() {
- ensure_starts_expanded(true);
- be_in_folder(folder);
-
- select_click_row(2);
- assert_selected_and_displayed(2);
-
- assert_true(
- !mc.e("attachmentList").collapsed,
- "Attachment list should start out expanded!"
- );
-}
-
-function test_selected_attachments_are_cleared() {
- ensure_starts_expanded(false);
- be_in_folder(folder);
- // First, select the message with two attachments.
- select_click_row(3);
-
- // Expand the attachment list.
- mc.click(mc.eid("attachmentToggle"));
-
- // Select both the attachments.
- let attachmentList = mc.e("attachmentList");
- assert_equals(
- attachmentList.selectedItems.length,
- 1,
- "On first load the first item should be selected"
- );
-
- // We can just click on the first element, but the second one needs a
- // ctrl-click (or cmd-click for those Mac-heads among us).
- mc.click(new elib.Elem(attachmentList.children[0]), 5, 5);
- EventUtils.synthesizeMouse(
- attachmentList.children[1],
- 5,
- 5,
- { accelKey: true },
- mc.window
- );
-
- assert_equals(
- attachmentList.selectedItems.length,
- 2,
- "We had the wrong number of selected items after selecting some!"
- );
-
- // Switch to the message with one attachment, and make sure there are no
- // selected attachments.
- select_click_row(2);
-
- // Expand the attachment list again.
- mc.click(mc.eid("attachmentToggle"));
-
- assert_equals(
- attachmentList.selectedItems.length,
- 1,
- "After loading a new message the first item should be selected"
- );
-}
-
-function test_select_all_attachments_key() {
- be_in_folder(folder);
-
- // First, select the message with two attachments.
- select_none();
- select_click_row(3);
-
- // Expand the attachment list.
- mc.click(mc.eid("attachmentToggle"));
-
- let attachmentList = mc.e("attachmentList");
- mc.keypress(new elib.Elem(attachmentList), "a", { accelKey: true });
- assert_equals(
- attachmentList.selectedItems.length,
- 2,
- "Should have selected all attachments!"
- );
-}
-
-function test_delete_attachment_key() {
- be_in_folder(folder);
-
- // First, select the message with two attachments.
- select_none();
- select_click_row(3);
-
- // Expand the attachment list.
- mc.click(mc.eid("attachmentToggle"));
-
- let firstAttachment = new elib.Elem(mc.e("attachmentList").firstElementChild);
- mc.click(firstAttachment, 5, 5);
-
- // Try deleting with the delete key
- plan_for_modal_dialog("commonDialogWindow", function(cdc) {
- cdc.window.document.documentElement.querySelector("dialog").cancelDialog();
- });
- mc.keypress(firstAttachment, "VK_DELETE", {});
- wait_for_modal_dialog("commonDialogWindow");
-
- // Try deleting with the shift-delete key combo.
- plan_for_modal_dialog("commonDialogWindow", function(cdc) {
- cdc.window.document.documentElement.querySelector("dialog").cancelDialog();
- });
- mc.keypress(firstAttachment, "VK_DELETE", { shiftKey: true });
- wait_for_modal_dialog("commonDialogWindow");
-}
-
-function test_attachments_compose_menu() {
- be_in_folder(folder);
-
- // First, select the message with two attachments.
- select_none();
- select_click_row(3);
-
- let cwc = open_compose_with_forward();
- let attachment = cwc.e("attachmentBucket");
-
- // On Linux and OSX, focus events don't seem to be sent to child elements properly if
- // the parent window is not focused. This causes some random oranges for us.
- // We use the force_focus function to "cheat" a bit, and trigger the function
- // that focusing normally would fire. We do normal focusing for Windows.
- function force_focus(aId) {
- let element = cwc.e(aId);
- element.focus();
-
- if (!mc.mozmillModule.isWindows) {
- // First, call the window's default controller's function.
- cwc.window.defaultController.isCommandEnabled("cmd_delete");
-
- // Walk up the DOM tree and call isCommandEnabled on the first controller
- // that supports "cmd_delete".
- while (element != cwc.window.document) {
- for (let i = 0; i < element.controllers.getControllerCount(); i++) {
- let currController = element.controllers.getControllerAt(i);
- if (currController.supportsCommand("cmd_delete")) {
- currController.isCommandEnabled("cmd_delete");
- return;
- }
- }
- element = element.parentNode;
- }
- }
- }
-
- // Click on a portion of the attachmentBucket that will focus it, but not
- // bring up the file picker
- force_focus("attachmentBucket");
- assert_equals(
- "Remove Attachments",
- cwc.e("cmd_delete").getAttribute("label"),
- "attachmentBucket is focused!"
- );
-
- // Select 1 attachment, and
- // focus the subject to see the label change and to execute isCommandEnabled
- attachment.selectedIndex = 0;
- force_focus("msgSubject");
- assert_equals(
- "Delete",
- cwc.e("cmd_delete").getAttribute("label"),
- "attachmentBucket is not focused!"
- );
-
- // Focus back to the attachmentBucket
- force_focus("attachmentBucket");
- assert_equals(
- "Remove Attachment",
- cwc.e("cmd_delete").getAttribute("label"),
- "Only 1 attachment is selected!"
- );
-
- // Select multiple attachments, and focus the identity for the same purpose
- attachment.selectAll();
- force_focus("msgIdentity");
- assert_equals(
- "Delete",
- cwc.e("cmd_delete").getAttribute("label"),
- "attachmentBucket is not focused!"
- );
-
- // Focus back to the attachmentBucket
- force_focus("attachmentBucket");
- assert_equals(
- "Remove Attachments",
- cwc.e("cmd_delete").getAttribute("label"),
- "Multiple attachments are selected!"
- );
-
- close_compose_window(cwc);
-}
-
-function test_delete_from_toolbar() {
- be_in_folder(folder);
-
- // First, select the message with two attachments.
- select_none();
- select_click_row(3);
-
- // Expand the attachment list.
- mc.click(mc.eid("attachmentToggle"));
-
- let firstAttachment = new elib.Elem(mc.e("attachmentList").firstElementChild);
- mc.click(firstAttachment, 5, 5);
-
- // Make sure clicking the "Delete" toolbar button with an attachment focused
- // deletes the *message*.
- plan_to_wait_for_folder_events("DeleteOrMoveMsgCompleted");
- mc.click(mc.eid("hdrTrashButton"));
- wait_for_folder_events();
-}
deleted file mode 100644
--- a/mail/test/mozmill/cloudfile/data/testFile1
+++ /dev/null
@@ -1,1 +0,0 @@
-Thundercats single-origin coffee culpa, irony minim vero sunt laborum synth aesthetic. Wayfarers photo booth dolore 8-bit, DIY four loko skateboard forage portland id consectetur. Aesthetic aliquip raw denim aute tofu consequat. Before they sold out etsy cliche marfa, magna seitan fixie brooklyn voluptate laborum messenger bag chillwave narwhal truffaut. Cray cupidatat PBR delectus aliqua synth cillum gentrify. Aesthetic do vegan etsy locavore. Veniam assumenda ea, cupidatat aute vero qui.
deleted file mode 100644
--- a/mail/test/mozmill/cloudfile/data/testFile2
+++ /dev/null
@@ -1,3 +0,0 @@
-Nesciunt odio minim, cupidatat photo booth non post-ironic street art banh mi salvia duis aesthetic squid single-origin coffee. Ex DIY trust fund butcher, esse mustache consequat authentic bushwick twee gentrify hella PBR kogi sustainable. PBR nihil VHS veniam, occaecat dreamcatcher odio iphone irony vero seitan mollit fanny pack adipisicing. Swag jean shorts labore, aesthetic dolore letterpress gluten-free lomo ex wes anderson. Et street art cred Austin velit, raw denim do blog godard leggings. Accusamus adipisicing excepteur occaecat cray sriracha. Leggings brunch artisan occaecat, 3 wolf moon forage mlkshk ad farm-to-table.
-
-
deleted file mode 100644
--- a/mail/test/mozmill/cloudfile/data/testFile3
+++ /dev/null
@@ -1,3 +0,0 @@
-Commodo et laborum fingerstache semiotics etsy. Organic locavore next level, master cleanse raw denim consectetur wes anderson ethical tempor photo booth quis. Leggings pop-up sed trust fund. Chillwave godard velit high life, typewriter umami trust fund. Laboris aliquip assumenda you probably haven't heard of them exercitation portland. Ea do selvage, stumptown dolore etsy commodo tattooed kogi assumenda. Aute tempor carles consequat cray locavore.
-
-Craft beer consectetur anim ex fap consequat, helvetica hella nihil retro before they sold out letterpress cillum mlkshk. Deserunt tempor scenester put a bird on it kale chips mlkshk occaecat, et umami artisan letterpress raw denim sapiente. Echo park pork belly marfa sunt. Iphone aesthetic fanny pack mollit. Irony pork belly bespoke, shoreditch locavore fixie iphone officia mollit mlkshk consequat hoodie mixtape. Nisi consectetur locavore, godard whatever occaecat id blog ethical wolf hoodie PBR. Trust fund sunt mustache, enim eiusmod aesthetic helvetica leggings pinterest laboris polaroid brooklyn.
deleted file mode 100644
--- a/mail/test/mozmill/cloudfile/data/testFile4
+++ /dev/null
@@ -1,1 +0,0 @@
-Ullamco farm-to-table banh mi, echo park dolor lomo chillwave seitan cred ad mustache 3 wolf moon excepteur. Odd future placeat sint, cliche consequat portland banksy vinyl 3 wolf moon high life you probably haven't heard of them nisi jean shorts. Eu freegan skateboard, kogi etsy beard aliquip blog sapiente pour-over sunt. Cosby sweater jean shorts wayfarers keytar trust fund, four loko pitchfork pinterest forage semiotics lo-fi cray beard swag butcher. Odd future cred swag, pork belly keytar velit terry richardson locavore id brunch excepteur commodo occupy mollit pickled. Street art voluptate pickled fap, ad craft beer cupidatat messenger bag placeat helvetica. Enim raw denim occupy pork belly irure et.
deleted file mode 100644
--- a/mail/test/mozmill/cloudfile/html/settings-with-link.xhtml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- This Source Code Form is subject to the terms of the Mozilla Public
- - License, v. 2.0. If a copy of the MPL was not distributed with this file,
- - You can obtain one at http://mozilla.org/MPL/2.0/. -->
-<html xmlns="http://www.w3.org/1999/xhtml">
- <body>
- <a id="a" href="https://www.example.com/">Click me!</a>
- </body>
-</html>
deleted file mode 100644
--- a/mail/test/mozmill/cloudfile/test-cloudfile-attachment-item.js
+++ /dev/null
@@ -1,198 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests Filelink attachment item behaviour.
- */
-
-"use strict";
-
-var {
- gMockFilePicker,
- gMockFilePickReg,
- select_attachments,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/AttachmentHelpers.jsm"
-);
-var {
- collectFiles,
- getFile,
- gMockCloudfileManager,
- MockCloudfileAccount,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/CloudfileHelpers.jsm"
-);
-var {
- add_cloud_attachments,
- close_compose_window,
- open_compose_new_mail,
-} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
-var { assert_false, close_popup } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var kAttachmentItemContextID = "msgComposeAttachmentItemContext";
-
-var { cloudFileAccounts } = ChromeUtils.import(
- "resource:///modules/cloudFileAccounts.jsm"
-);
-
-function setupModule(module) {
- gMockFilePickReg.register();
- gMockCloudfileManager.register();
-}
-
-function teardownModule(module) {
- gMockCloudfileManager.unregister();
- gMockFilePickReg.unregister();
-}
-
-/**
- * Test that when an upload has been started, we can cancel and restart
- * the upload, and then cancel again. For this test, we repeat this
- * 3 times.
- */
-function test_upload_cancel_repeat() {
- const kFile = "./data/testFile1";
-
- // Prepare the mock file picker to return our test file.
- let file = getFile(kFile, __file__);
- gMockFilePicker.returnFiles = [file];
-
- let provider = new MockCloudfileAccount();
- provider.init("someKey");
- let cw = open_compose_new_mail();
-
- // We've got a compose window open, and our mock Filelink provider
- // ready. Let's attach a file...
- cw.window.AttachFile();
-
- // Now we override the uploadFile function of the MockCloudfileAccount
- // so that we're perpetually uploading...
- let promise;
- let started;
- provider.uploadFile = function(aFile) {
- return new Promise((resolve, reject) => {
- promise = { resolve, reject };
- started = true;
- });
- };
-
- const kAttempts = 3;
- for (let i = 0; i < kAttempts; i++) {
- promise = null;
- started = false;
-
- // Select the attachment, and choose to convert it to a Filelink
- select_attachments(cw, 0)[0];
- cw.window.convertSelectedToCloudAttachment(provider);
- cw.waitFor(() => started);
-
- assert_can_cancel_upload(cw, provider, promise, file);
- }
-
- close_compose_window(cw);
-}
-
-/**
- * Test that we can cancel a whole series of files being uploaded at once.
- */
-function test_upload_multiple_and_cancel() {
- const kFiles = ["./data/testFile1", "./data/testFile2", "./data/testFile3"];
-
- // Prepare the mock file picker to return our test file.
- let files = collectFiles(kFiles, __file__);
- gMockFilePicker.returnFiles = files;
-
- let provider = new MockCloudfileAccount();
- provider.init("someKey");
- let cw = open_compose_new_mail();
-
- let promise;
- provider.uploadFile = function(aFile) {
- return new Promise((resolve, reject) => {
- promise = { resolve, reject };
- });
- };
-
- add_cloud_attachments(cw, provider, false);
-
- for (let i = files.length - 1; i >= 0; --i) {
- assert_can_cancel_upload(cw, provider, promise, files[i]);
- }
-
- close_compose_window(cw);
-}
-
-/**
- * Helper function that takes an upload in progress, and cancels it,
- * ensuring that the nsIMsgCloduFileProvider.uploadCanceled status message
- * is returned to the passed in listener.
- *
- * @param aController the compose window controller to use.
- * @param aProvider a MockCloudfileAccount for which the uploads have already
- * started.
- * @param aListener the nsIRequestObserver passed to aProvider's uploadFile
- * function.
- * @param aTargetFile the nsIFile to cancel the upload for.
- */
-function assert_can_cancel_upload(
- aController,
- aProvider,
- aPromise,
- aTargetFile
-) {
- let cancelled = false;
-
- // Override the provider's cancelFileUpload function. We can do this because
- // it's assumed that the provider is a MockCloudfileAccount.
- aProvider.cancelFileUpload = function(aFileToCancel) {
- if (aTargetFile.equals(aFileToCancel)) {
- aPromise.reject(cloudFileAccounts.constants.uploadCancelled);
- cancelled = true;
- }
- };
-
- // Retrieve the attachment bucket index for the target file...
- let index = get_attachmentitem_index_for_file(aController, aTargetFile);
-
- // Select that attachmentitem in the bucket
- select_attachments(aController, index)[0];
-
- // Bring up the context menu, and click cancel.
- let cmd = aController.e("cmd_cancelUpload");
- aController.window.updateAttachmentItems();
-
- assert_false(cmd.hidden);
- assert_false(cmd.disabled);
- let cancelItem = aController.eid("composeAttachmentContext_cancelUploadItem");
- aController.click(cancelItem);
-
- // Close the popup, and wait for the cancellation to be complete.
- close_popup(aController, aController.eid(kAttachmentItemContextID));
- aController.waitFor(() => cancelled);
-}
-
-/**
- * A helper function to find the attachment bucket index for a particular
- * nsIFile. Returns null if no attachmentitem is found.
- *
- * @param aController the compose window controller to use.
- * @param aFile the nsIFile to search for.
- */
-function get_attachmentitem_index_for_file(aController, aFile) {
- // Get the fileUrl from the file.
- let fileUrl = aController.window.FileToAttachment(aFile).url;
-
- // Get the bucket, and go through each item looking for the matching
- // attachmentitem.
- let bucket = aController.e("attachmentBucket");
- for (let i = 0; i < bucket.getRowCount(); ++i) {
- let attachmentitem = bucket.getItemAtIndex(i);
- if (attachmentitem.attachment.url == fileUrl) {
- return i;
- }
- }
- return null;
-}
deleted file mode 100644
--- a/mail/test/mozmill/cloudfile/test-cloudfile-attachment-urls.js
+++ /dev/null
@@ -1,952 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests Filelink URL insertion behaviours in compose windows.
- */
-
-"use strict";
-
-var {
- gMockFilePicker,
- gMockFilePickReg,
- select_attachments,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/AttachmentHelpers.jsm"
-);
-var {
- collectFiles,
- gMockCloudfileManager,
- MockCloudfileAccount,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/CloudfileHelpers.jsm"
-);
-var {
- add_cloud_attachments,
- assert_previous_text,
- get_compose_body,
- open_compose_new_mail,
- open_compose_with_forward,
- open_compose_with_reply,
- type_in_composer,
-} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
-var {
- assert_next_nodes,
- assert_previous_nodes,
- wait_for_element,
-} = ChromeUtils.import("resource://testing-common/mozmill/DOMHelpers.jsm");
-var {
- add_message_to_folder,
- assert_equals,
- assert_not_equals,
- assert_selected_and_displayed,
- assert_true,
- be_in_folder,
- create_message,
- FAKE_SERVER_HOSTNAME,
- get_special_folder,
- mc,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { close_window } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-var kUploadedFile = "attachment-uploaded";
-var kHtmlPrefKey = "mail.identity.default.compose_html";
-var kReplyOnTopKey = "mail.identity.default.reply_on_top";
-var kReplyOnTop = 1;
-var kReplyOnBottom = 0;
-var kTextNodeType = 3;
-var kSigPrefKey = "mail.identity.id1.htmlSigText";
-var kSigOnReplyKey = "mail.identity.default.sig_on_reply";
-var kSigOnForwardKey = "mail.identity.default.sig_on_fwd";
-var kDefaultSigKey = "mail.identity.id1.htmlSigText";
-var kDefaultSig = "This is my signature.\n\nCheck out my website sometime!";
-var kFiles = ["./data/testFile1", "./data/testFile2"];
-var kLines = ["This is a line of text", "and here's another!"];
-
-var gInbox, gOldHtmlPref, gOldSigPref;
-
-function setupModule(module) {
- // For replies and forwards, we'll work off a message in the Inbox folder
- // of the fake "tinderbox" account.
- let server = MailServices.accounts.FindServer(
- "tinderbox",
- FAKE_SERVER_HOSTNAME,
- "pop3"
- );
- gInbox = get_special_folder(Ci.nsMsgFolderFlags.Inbox, false, server);
- add_message_to_folder(gInbox, create_message());
-
- gMockFilePickReg.register();
- gMockCloudfileManager.register();
-
- // These tests assume that we default to writing mail in HTML. We'll
- // save the current preference, force defaulting to HTML, and restore the
- // pref in teardownModule.
- gOldHtmlPref = Services.prefs.getBoolPref(kHtmlPrefKey);
- Services.prefs.setBoolPref(kHtmlPrefKey, true);
- // Same goes for the default signature.
- gOldSigPref = Services.prefs.getCharPref(kDefaultSigKey);
-
- // Don't create paragraphs in the test.
- // The test fails if it encounters paragraphs <p> instead of breaks <br>.
- Services.prefs.setBoolPref("mail.compose.default_to_paragraph", false);
-}
-
-function teardownModule(module) {
- gMockCloudfileManager.unregister();
- gMockFilePickReg.unregister();
- Services.prefs.setCharPref(kDefaultSigKey, gOldSigPref);
- Services.prefs.setBoolPref(kHtmlPrefKey, gOldHtmlPref);
- Services.prefs.clearUserPref("mail.compose.default_to_paragraph");
-}
-
-function setupTest() {
- // If our signature got accidentally wiped out, let's just put it back.
- Services.prefs.setCharPref(kDefaultSigKey, kDefaultSig);
-}
-
-/**
- * Given some compose window controller, wait for some Filelink URLs to be
- * inserted.
- *
- * @param aController the controller for a compose window.
- * @param aNumUrls the number of Filelink URLs that are expected.
- * @returns an array containing the root containment node, the list node, and
- * an array of the link URL nodes.
- */
-function wait_for_attachment_urls(aController, aNumUrls) {
- let mailBody = get_compose_body(aController);
-
- // Wait until we can find the root attachment URL node...
- let root = wait_for_element(
- mailBody.parentNode,
- "body > #cloudAttachmentListRoot"
- );
-
- let list = wait_for_element(
- mailBody,
- "#cloudAttachmentListRoot > #cloudAttachmentList"
- );
-
- let urls = null;
- aController.waitFor(function() {
- urls = mailBody.querySelectorAll(
- "#cloudAttachmentList > .cloudAttachmentItem"
- );
- return urls != null && urls.length == aNumUrls;
- });
-
- return [root, list, urls];
-}
-
-/**
- * Helper function that sets up the mock file picker for a series of files,
- * spawns a reply window for the first message in the gInbox, optionally
- * types some strings into the compose window, and then attaches some
- * Filelinks.
- *
- * @param aText an array of strings to type into the compose window. Each
- * string is followed by pressing the RETURN key, except for
- * the final string. Pass an empty array if you don't want
- * anything typed.
- * @param aFiles an array of filename strings for files located beneath
- * the test directory.
- */
-function prepare_some_attachments_and_reply(aText, aFiles) {
- gMockFilePicker.returnFiles = collectFiles(aFiles, __file__);
-
- let provider = new MockCloudfileAccount();
- provider.init("someKey");
-
- be_in_folder(gInbox);
- let msg = select_click_row(0);
- assert_selected_and_displayed(mc, msg);
-
- let cw = open_compose_with_reply();
-
- // If we have any typing to do, let's do it.
- type_in_composer(cw, aText);
- add_cloud_attachments(cw, provider);
- return cw;
-}
-
-/**
- * Helper function that sets up the mock file picker for a series of files,
- * spawns an inline forward compose window for the first message in the gInbox,
- * optionally types some strings into the compose window, and then attaches
- * some Filelinks.
- *
- * @param aText an array of strings to type into the compose window. Each
- * string is followed by pressing the RETURN key, except for
- * the final string. Pass an empty array if you don't want
- * anything typed.
- * @param aFiles an array of filename strings for files located beneath
- * the test directory.
- */
-function prepare_some_attachments_and_forward(aText, aFiles) {
- gMockFilePicker.returnFiles = collectFiles(aFiles, __file__);
-
- let provider = new MockCloudfileAccount();
- provider.init("someKey");
-
- be_in_folder(gInbox);
- let msg = select_click_row(0);
- assert_selected_and_displayed(mc, msg);
-
- let cw = open_compose_with_forward();
-
- // Put the selection at the beginning of the document...
- let editor = cw.window.GetCurrentEditor();
- editor.beginningOfDocument();
-
- // Do any necessary typing...
- type_in_composer(cw, aText);
- add_cloud_attachments(cw, provider);
- return cw;
-}
-
-/**
- * Helper function that runs a test function with signature-in-reply and
- * signature-in-forward enabled, and then runs the test again with those
- * prefs disabled.
- *
- * @param aSpecialTest a test that takes two arguments - the first argument
- * is the aText array of any text that should be typed,
- * and the second is a boolean for whether or not the
- * special test should expect a signature or not.
- * @param aText any text to be typed into the compose window, passed to
- * aSpecialTest.
- */
-function try_with_and_without_signature_in_reply_or_fwd(aSpecialTest, aText) {
- // By default, we have a signature included in replies, so we'll start
- // with that.
- Services.prefs.setBoolPref(kSigOnReplyKey, true);
- Services.prefs.setBoolPref(kSigOnForwardKey, true);
- aSpecialTest(aText, true);
-
- Services.prefs.setBoolPref(kSigOnReplyKey, false);
- Services.prefs.setBoolPref(kSigOnForwardKey, false);
- aSpecialTest(aText, false);
-}
-
-/**
- * Helper function that runs a test function without a signature, once
- * in HTML mode, and again in plaintext mode.
- *
- * @param aTest a test that takes no arguments.
- */
-function try_without_signature(aTest) {
- let oldSig = Services.prefs.getCharPref(kSigPrefKey);
- Services.prefs.setCharPref(kSigPrefKey, "");
-
- try_with_plaintext_and_html_mail(aTest);
- Services.prefs.setCharPref(kSigPrefKey, oldSig);
-}
-
-/**
- * Helper function that runs a test function for HTML mail composition, and
- * then again in plaintext mail composition.
- *
- * @param aTest a test that takes no arguments.
- */
-function try_with_plaintext_and_html_mail(aTest) {
- aTest();
- Services.prefs.setBoolPref(kHtmlPrefKey, false);
- aTest();
- Services.prefs.setBoolPref(kHtmlPrefKey, true);
-}
-
-/**
- * Test that if we open up a composer and immediately attach a Filelink,
- * a linebreak is inserted before the containment node in order to allow
- * the user to write before the attachment URLs. This assumes the user
- * does not have a signature already inserted into the message body.
- */
-function test_inserts_linebreak_on_empty_compose() {
- try_without_signature(subtest_inserts_linebreak_on_empty_compose);
-}
-
-/**
- * Subtest for test_inserts_linebreak_on_empty_compose - can be executed
- * on both plaintext and HTML compose windows.
- */
-function subtest_inserts_linebreak_on_empty_compose() {
- gMockFilePicker.returnFiles = collectFiles(kFiles, __file__);
- let provider = new MockCloudfileAccount();
- provider.init("someKey");
- let cw = open_compose_new_mail();
- add_cloud_attachments(cw, provider);
-
- let [root] = wait_for_attachment_urls(cw, kFiles.length);
-
- let br = root.previousSibling;
- assert_equals(
- br.localName,
- "br",
- "The attachment URL containment node should be preceded by a linebreak"
- );
-
- let mailBody = get_compose_body(cw);
-
- assert_equals(
- mailBody.firstChild,
- br,
- "The linebreak should be the first child of the compose body"
- );
-
- close_window(cw);
-}
-
-/**
- * Test that if we open up a composer and immediately attach a Filelink,
- * a linebreak is inserted before the containment node. This test also
- * ensures that, with a signature already in the compose window, we don't
- * accidentally insert the attachment URL containment within the signature
- * node.
- */
-function test_inserts_linebreak_on_empty_compose_with_signature() {
- gMockFilePicker.returnFiles = collectFiles(kFiles, __file__);
- let provider = new MockCloudfileAccount();
- provider.init("someKey");
- let cw = open_compose_new_mail();
- add_cloud_attachments(cw, provider);
- // wait_for_attachment_urls ensures that the attachment URL containment
- // node is an immediate child of the body of the message, so if this
- // succeeds, then we were not in the signature node.
- let [root] = wait_for_attachment_urls(cw, kFiles.length);
-
- let br = assert_previous_nodes("br", root, 1);
-
- let mailBody = get_compose_body(cw);
- assert_equals(
- mailBody.firstChild,
- br,
- "The linebreak should be the first child of the compose body"
- );
-
- // Now ensure that the node after the attachments is a br, and following
- // that is the signature.
- br = assert_next_nodes("br", root, 1);
-
- let pre = br.nextSibling;
- assert_equals(
- pre.localName,
- "pre",
- "The linebreak should be followed by the signature pre"
- );
- assert_true(
- pre.classList.contains("moz-signature"),
- "The pre should have the moz-signature class"
- );
-
- close_window(cw);
-
- Services.prefs.setBoolPref(kHtmlPrefKey, false);
-
- // Now let's try with plaintext mail.
- cw = open_compose_new_mail();
- add_cloud_attachments(cw, provider);
- [root] = wait_for_attachment_urls(cw, kFiles.length);
-
- br = assert_previous_nodes("br", root, 1);
-
- mailBody = get_compose_body(cw);
- assert_equals(
- mailBody.firstChild,
- br,
- "The linebreak should be the first child of the compose body"
- );
-
- // Now ensure that the node after the attachments is a br, and following
- // that is the signature.
- br = assert_next_nodes("br", root, 1);
-
- let div = br.nextSibling;
- assert_equals(
- div.localName,
- "div",
- "The linebreak should be followed by the signature div"
- );
- assert_true(
- div.classList.contains("moz-signature"),
- "The div should have the moz-signature class"
- );
-
- close_window(cw);
-
- Services.prefs.setBoolPref(kHtmlPrefKey, true);
-}
-
-/**
- * Tests that removing all Filelinks causes the root node to be removed.
- */
-function test_removing_filelinks_removes_root_node() {
- try_with_plaintext_and_html_mail(
- subtest_removing_filelinks_removes_root_node
- );
-}
-
-/**
- * Test for test_removing_filelinks_removes_root_node - can be executed
- * on both plaintext and HTML compose windows.
- */
-function subtest_removing_filelinks_removes_root_node() {
- let cw = prepare_some_attachments_and_reply([], kFiles);
- let [root] = wait_for_attachment_urls(cw, kFiles.length);
-
- // Now select the attachments in the attachment bucket, and remove them.
- select_attachments(cw, 0, 1);
- cw.window.goDoCommand("cmd_delete");
-
- // Wait for the root to be removed.
- let mailBody = get_compose_body(cw);
- cw.waitFor(function() {
- let result = mailBody.querySelector(root.id);
- return result == null;
- }, "Timed out waiting for attachment container to be removed");
-
- close_window(cw);
-}
-
-/**
- * Test that if we write some text in an empty message (no signature),
- * and the selection is at the end of a line of text, attaching some Filelinks
- * causes the attachment URL container to be separated from the text by
- * two br tags.
- */
-function test_adding_filelinks_to_written_message() {
- try_without_signature(subtest_adding_filelinks_to_written_message);
-}
-
-/**
- * Subtest for test_adding_filelinks_to_written_message - generalized for both
- * HTML and plaintext mail.
- */
-function subtest_adding_filelinks_to_written_message() {
- gMockFilePicker.returnFiles = collectFiles(kFiles, __file__);
- let provider = new MockCloudfileAccount();
- provider.init("someKey");
- let cw = open_compose_new_mail();
-
- type_in_composer(cw, kLines);
- add_cloud_attachments(cw, provider);
-
- let [root] = wait_for_attachment_urls(cw, kFiles.length);
-
- let br = root.previousSibling;
- assert_equals(
- br.localName,
- "br",
- "The attachment URL containment node should be preceded by a linebreak"
- );
- br = br.previousSibling;
- assert_equals(
- br.localName,
- "br",
- "The attachment URL containment node should be preceded by " +
- "two linebreaks"
- );
- close_window(cw);
-}
-
-/**
- * Tests for inserting Filelinks into a reply, when we're configured to
- * reply above the quote.
- */
-function test_adding_filelinks_to_empty_reply_above() {
- let oldReplyOnTop = Services.prefs.getIntPref(kReplyOnTopKey);
- Services.prefs.setIntPref(kReplyOnTopKey, kReplyOnTop);
-
- try_with_and_without_signature_in_reply_or_fwd(
- subtest_adding_filelinks_to_reply_above,
- []
- );
- // Now with HTML mail...
- Services.prefs.setBoolPref(kHtmlPrefKey, false);
- try_with_and_without_signature_in_reply_or_fwd(
- subtest_adding_filelinks_to_reply_above_plaintext,
- []
- );
-
- Services.prefs.setBoolPref(kHtmlPrefKey, true);
- Services.prefs.setIntPref(kReplyOnTopKey, oldReplyOnTop);
-}
-
-/**
- * Tests for inserting Filelinks into a reply, when we're configured to
- * reply above the quote, after entering some text.
- */
-function test_adding_filelinks_to_nonempty_reply_above() {
- let oldReplyOnTop = Services.prefs.getIntPref(kReplyOnTopKey);
- Services.prefs.setIntPref(kReplyOnTopKey, kReplyOnTop);
-
- subtest_adding_filelinks_to_reply_above(kLines);
-
- Services.prefs.setBoolPref(kHtmlPrefKey, false);
- subtest_adding_filelinks_to_reply_above_plaintext(kLines);
- Services.prefs.setBoolPref(kHtmlPrefKey, true);
-
- Services.prefs.setIntPref(kReplyOnTopKey, oldReplyOnTop);
-}
-
-/**
- * Subtest for test_adding_filelinks_to_reply_above for the plaintext composer.
- * Does some special casing for the weird br insertions that happens in
- * various cases.
- */
-function subtest_adding_filelinks_to_reply_above_plaintext(aText, aWithSig) {
- let cw = prepare_some_attachments_and_reply(aText, kFiles);
- let [root] = wait_for_attachment_urls(cw, kFiles.length);
-
- let br;
- if (aText.length) {
- br = assert_next_nodes("br", root, 2);
- } else {
- br = assert_next_nodes("br", root, 1);
- }
-
- let div = br.nextSibling;
- assert_equals(
- div.localName,
- "div",
- "The linebreak should be followed by a div"
- );
-
- assert_true(div.classList.contains("moz-cite-prefix"));
-
- if (aText.length) {
- br = assert_previous_nodes("br", root, 2);
- } else {
- br = assert_previous_nodes("br", root, 1);
- }
-
- if (aText.length == 0) {
- // If we didn't type anything, that br should be the first element of the
- // message body.
- let msgBody = get_compose_body(cw);
- assert_equals(
- msgBody.firstChild,
- br,
- "The linebreak should have been the first element in the " +
- "message body"
- );
- } else {
- let targetText = aText[aText.length - 1];
- let textNode = br.previousSibling;
- assert_equals(textNode.nodeType, kTextNodeType);
- assert_equals(textNode.nodeValue, targetText);
- }
-
- close_window(cw);
-}
-
-/**
- * Subtest for test_adding_filelinks_to_reply_above for the HTML composer.
- */
-function subtest_adding_filelinks_to_reply_above(aText) {
- let cw = prepare_some_attachments_and_reply(aText, kFiles);
- let [root] = wait_for_attachment_urls(cw, kFiles.length);
-
- // If there's any text written, then there's only a single break between the
- // end of the text and the reply. Otherwise, there are two breaks.
- let br =
- aText.length > 1
- ? assert_next_nodes("br", root, 2)
- : assert_next_nodes("br", root, 1);
-
- // ... which is followed by a div with a class of "moz-cite-prefix".
- let div = br.nextSibling;
- assert_equals(
- div.localName,
- "div",
- "The linebreak should be followed by a div"
- );
-
- assert_true(div.classList.contains("moz-cite-prefix"));
-
- close_window(cw);
-}
-
-/**
- * Tests for inserting Filelinks into a reply, when we're configured to
- * reply below the quote.
- */
-function test_adding_filelinks_to_empty_reply_below() {
- let oldReplyOnTop = Services.prefs.getIntPref(kReplyOnTopKey);
- Services.prefs.setIntPref(kReplyOnTopKey, kReplyOnBottom);
-
- try_with_and_without_signature_in_reply_or_fwd(
- subtest_adding_filelinks_to_reply_below,
- []
- );
- Services.prefs.setBoolPref(kHtmlPrefKey, false);
- try_with_and_without_signature_in_reply_or_fwd(
- subtest_adding_filelinks_to_plaintext_reply_below,
- []
- );
- Services.prefs.setBoolPref(kHtmlPrefKey, true);
-
- Services.prefs.setIntPref(kReplyOnTopKey, oldReplyOnTop);
-}
-
-/**
- * Tests for inserting Filelinks into a reply, when we're configured to
- * reply below the quote, after entering some text.
- */
-function test_adding_filelinks_to_nonempty_reply_below() {
- let oldReplyOnTop = Services.prefs.getIntPref(kReplyOnTopKey);
- Services.prefs.setIntPref(kReplyOnTopKey, kReplyOnBottom);
-
- try_with_and_without_signature_in_reply_or_fwd(
- subtest_adding_filelinks_to_reply_below,
- kLines
- );
-
- Services.prefs.setBoolPref(kHtmlPrefKey, false);
- try_with_and_without_signature_in_reply_or_fwd(
- subtest_adding_filelinks_to_plaintext_reply_below,
- kLines
- );
- Services.prefs.setBoolPref(kHtmlPrefKey, true);
-
- Services.prefs.setIntPref(kReplyOnTopKey, oldReplyOnTop);
-}
-
-/**
- * Subtest for test_adding_filelinks_to_reply_below for the HTML composer.
- */
-function subtest_adding_filelinks_to_reply_below(aText, aWithSig) {
- let cw = prepare_some_attachments_and_reply(aText, kFiles);
- let [root] = wait_for_attachment_urls(cw, kFiles.length);
- // So, we should have the root, followed by a br
- let br = root.nextSibling;
- assert_equals(
- br.localName,
- "br",
- "The attachment URL containment node should be followed by a br"
- );
-
- let blockquote;
- if (aText.length) {
- // If there was any text inserted, check for 2 previous br nodes, and then
- // the inserted text, and then the blockquote.
- br = assert_previous_nodes("br", root, 2);
- let textNode = assert_previous_text(br.previousSibling, aText);
- blockquote = textNode.previousSibling;
- } else {
- // If no text was inserted, check for 1 previous br node, and then the
- // blockquote.
- br = assert_previous_nodes("br", root, 1);
- blockquote = br.previousSibling;
- }
-
- assert_equals(
- blockquote.localName,
- "blockquote",
- "The linebreak should be preceded by a blockquote."
- );
-
- let prefix = blockquote.previousSibling;
- assert_equals(
- prefix.localName,
- "div",
- "The blockquote should be preceded by the prefix div"
- );
- assert_true(
- prefix.classList.contains("moz-cite-prefix"),
- "The prefix should have the moz-cite-prefix class"
- );
-
- close_window(cw);
-}
-
-/**
- * Subtest for test_adding_filelinks_to_reply_below for the plaintext composer.
- */
-function subtest_adding_filelinks_to_plaintext_reply_below(aText, aWithSig) {
- let cw = prepare_some_attachments_and_reply(aText, kFiles);
- let [root] = wait_for_attachment_urls(cw, kFiles.length);
-
- let br, span;
-
- assert_next_nodes("br", root, 1);
-
- if (aText.length) {
- br = assert_previous_nodes("br", root, 2);
- // If text was entered, make sure it matches what we expect...
- let textNode = assert_previous_text(br.previousSibling, aText);
- // And then grab the span, which should be before the final text node.
- span = textNode.previousSibling;
- } else {
- br = assert_previous_nodes("br", root, 1);
- // If no text was entered, just grab the last br's previous sibling - that
- // will be the span.
- span = br.previousSibling;
- // Sometimes we need to skip one more linebreak.
- if (span.localName != "span") {
- span = span.previousSibling;
- }
- }
-
- assert_equals(
- span.localName,
- "span",
- "The linebreak should be preceded by a span."
- );
-
- let prefix = span.previousSibling;
- assert_equals(
- prefix.localName,
- "div",
- "The blockquote should be preceded by the prefix div"
- );
- assert_true(
- prefix.classList.contains("moz-cite-prefix"),
- "The prefix should have the moz-cite-prefix class"
- );
-
- close_window(cw);
-}
-
-/**
- * Tests Filelink insertion on an inline-forward compose window with nothing
- * typed into it.
- */
-function test_adding_filelinks_to_empty_forward() {
- Services.prefs.setIntPref(kReplyOnTopKey, kReplyOnTop);
- try_with_and_without_signature_in_reply_or_fwd(
- subtest_adding_filelinks_to_forward,
- []
- );
- Services.prefs.setBoolPref(kHtmlPrefKey, false);
- try_with_and_without_signature_in_reply_or_fwd(
- subtest_adding_filelinks_to_forward,
- []
- );
- Services.prefs.setBoolPref(kHtmlPrefKey, true);
-}
-
-/**
- * Tests Filelink insertion on an inline-forward compose window with some
- * text typed into it.
- */
-function test_adding_filelinks_to_forward() {
- try_with_and_without_signature_in_reply_or_fwd(
- subtest_adding_filelinks_to_forward,
- kLines
- );
- Services.prefs.setBoolPref(kHtmlPrefKey, false);
- try_with_and_without_signature_in_reply_or_fwd(
- subtest_adding_filelinks_to_forward,
- kLines
- );
- Services.prefs.setBoolPref(kHtmlPrefKey, true);
-}
-
-/**
- * Subtest for both test_adding_filelinks_to_empty_forward and
- * test_adding_filelinks_to_forward - ensures that the inserted Filelinks
- * are positioned correctly.
- */
-function subtest_adding_filelinks_to_forward(aText, aWithSig) {
- let cw = prepare_some_attachments_and_forward(aText, kFiles);
- let [root] = wait_for_attachment_urls(cw, kFiles.length);
-
- let br = assert_next_nodes("br", root, 1);
- let forwardDiv = br.nextSibling;
- assert_equals(forwardDiv.localName, "div");
- assert_true(forwardDiv.classList.contains("moz-forward-container"));
-
- if (aText.length) {
- // If there was text typed in, it should be separated from the root by two
- // br's
- let br = assert_previous_nodes("br", root, 2);
- assert_previous_text(br.previousSibling, aText);
- } else {
- // Otherwise, there's only 1 br, and that br should be the first element
- // of the message body.
- let br = assert_previous_nodes("br", root, 1);
- let mailBody = get_compose_body(cw);
- assert_equals(br, mailBody.firstChild);
- }
-
- close_window(cw);
-}
-
-/**
- * Test that if we convert a Filelink from one provider to another, that the
- * old Filelink is removed, and a new Filelink is added for the new provider.
- * We test this on both HTML and plaintext mail.
- */
-function test_converting_filelink_updates_urls() {
- try_with_plaintext_and_html_mail(subtest_converting_filelink_updates_urls);
-}
-
-/**
- * Subtest for test_converting_filelink_updates_urls that creates two
- * storage provider accounts, uploads files to one, converts them to the
- * other, and ensures that the attachment links in the message body get
- * get updated.
- */
-function subtest_converting_filelink_updates_urls() {
- gMockFilePicker.returnFiles = collectFiles(kFiles, __file__);
- let providerA = new MockCloudfileAccount();
- let providerB = new MockCloudfileAccount();
- providerA.init("providerA");
- providerB.init("providerB");
-
- let cw = open_compose_new_mail();
- add_cloud_attachments(cw, providerA);
-
- let [, , urls] = wait_for_attachment_urls(cw, kFiles.length);
-
- // Convert each Filelink to providerB, ensuring that the URLs are replaced.
- for (let i = 0; i < kFiles.length; ++i) {
- let url = urls[i];
- select_attachments(cw, i);
- cw.window.convertSelectedToCloudAttachment(providerB);
- [, , urls] = wait_for_attachment_urls(cw, kFiles.length);
-
- let newUrl = urls[i];
-
- assert_not_equals(
- url,
- newUrl,
- "The original URL should have been replaced"
- );
- }
-
- close_window(cw);
-}
-
-/**
- * Test that if we convert a Filelink to a normal attachment that the
- * Filelink is removed from the message body.
- */
-function test_converting_filelink_to_normal_removes_url() {
- try_with_plaintext_and_html_mail(
- subtest_converting_filelink_to_normal_removes_url
- );
-}
-
-/**
- * Subtest for test_converting_filelink_to_normal_removes_url that adds
- * some Filelinks to an email, and then converts those Filelinks back into
- * normal attachments, checking to ensure that the links are removed from
- * the body of the email.
- */
-function subtest_converting_filelink_to_normal_removes_url() {
- gMockFilePicker.returnFiles = collectFiles(kFiles, __file__);
- let provider = new MockCloudfileAccount();
- provider.init("someKey");
-
- let cw = open_compose_new_mail();
- add_cloud_attachments(cw, provider);
-
- let [root, list] = wait_for_attachment_urls(cw, kFiles.length);
-
- for (let i = 0; i < kFiles.length; ++i) {
- select_attachments(cw, i);
- cw.window.convertSelectedToRegularAttachment();
-
- let urls = list.querySelectorAll(".cloudAttachmentItem");
- assert_equals(urls.length, kFiles.length - (i + 1));
- }
-
- // At this point, the root should also have been removed.
- let mailBody = get_compose_body(cw);
- root = mailBody.querySelector("#cloudAttachmentListRoot");
- if (root) {
- throw new Error("Should not have found the cloudAttachmentListRoot");
- }
-
- close_window(cw);
-}
-
-/**
- * Tests that if the user manually removes the Filelinks from the message body
- * that it doesn't break future Filelink insertions. Tests both HTML and
- * plaintext composers.
- */
-function test_filelinks_work_after_manual_removal() {
- try_with_plaintext_and_html_mail(subtest_filelinks_work_after_manual_removal);
-}
-
-/**
- * Subtest that first adds some Filelinks to the message body, removes them,
- * and then adds another Filelink ensuring that the new URL is successfully
- * inserted.
- */
-function subtest_filelinks_work_after_manual_removal() {
- // Insert some Filelinks...
- gMockFilePicker.returnFiles = collectFiles(kFiles, __file__);
- let provider = new MockCloudfileAccount();
- provider.init("someKey");
- let cw = open_compose_new_mail();
- add_cloud_attachments(cw, provider);
-
- let [root] = wait_for_attachment_urls(cw, kFiles.length);
-
- // Now remove the root node from the document body
- root.remove();
-
- gMockFilePicker.returnFiles = collectFiles(["./data/testFile3"], __file__);
- add_cloud_attachments(cw, provider);
- [root] = wait_for_attachment_urls(cw, 1);
-
- close_window(cw);
-}
-
-/**
- * Test that if the users selection caret is on a newline when the URL
- * insertion occurs, that the caret does not move when the insertion is
- * complete. Tests both HTML and plaintext composers.
- */
-function test_insertion_restores_caret_point() {
- try_with_plaintext_and_html_mail(subtest_insertion_restores_caret_point);
-}
-
-/**
- * Subtest that types some things into the composer, finishes on two
- * linebreaks, inserts some Filelink URLs, and then types some more,
- * ensuring that the selection is where we expect it to be.
- */
-function subtest_insertion_restores_caret_point() {
- // Insert some Filelinks...
- gMockFilePicker.returnFiles = collectFiles(kFiles, __file__);
- let provider = new MockCloudfileAccount();
- provider.init("someKey");
-
- let cw = open_compose_new_mail();
-
- // Put the selection at the beginning of the document...
- let editor = cw.window.GetCurrentEditor();
- editor.beginningOfDocument();
-
- // Do any necessary typing, ending with two linebreaks.
- type_in_composer(cw, ["Line 1", "Line 2", "", ""]);
-
- // Attach some Filelinks.
- add_cloud_attachments(cw, provider);
- let [root] = wait_for_attachment_urls(cw, kFiles.length);
-
- // Type some text.
- const kTypedIn = "Test";
- type_in_composer(cw, [kTypedIn]);
-
- // That text should be inserted just above the root attachment URL node.
- assert_previous_text(root.previousSibling, [kTypedIn]);
-
- close_window(cw);
-}
deleted file mode 100644
--- a/mail/test/mozmill/cloudfile/test-cloudfile-manager.js
+++ /dev/null
@@ -1,119 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests the richlistbox in the manager for attachment storage
- * services
- */
-
-"use strict";
-
-var { gMockCloudfileManager } = ChromeUtils.import(
- "resource://testing-common/mozmill/CloudfileHelpers.jsm"
-);
-var { content_tab_e, gMockExtProtSvc, gMockExtProtSvcReg } = ChromeUtils.import(
- "resource://testing-common/mozmill/ContentTabHelpers.jsm"
-);
-var { assert_equals, mc } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { close_pref_tab, open_pref_tab } = ChromeUtils.import(
- "resource://testing-common/mozmill/PrefTabHelpers.jsm"
-);
-var { wait_for_frame_load } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var kTestAccountType = "mock";
-var kRootURL = collector.addHttpResource("../cloudfile/html", "");
-var kSettingsWithLink = kRootURL + "settings-with-link.xhtml";
-
-function setupModule(module) {
- gMockCloudfileManager.register(kTestAccountType, {
- managementURL: kSettingsWithLink,
- });
-
- // Let's set up a few dummy accounts;
- create_dummy_account("someKey1", kTestAccountType, "carl's Account");
- create_dummy_account("someKey2", kTestAccountType, "Amber's Account");
- create_dummy_account("someKey3", kTestAccountType, "alice's Account");
- create_dummy_account("someKey4", kTestAccountType, "Bob's Account");
-}
-
-function teardownModule(module) {
- Services.prefs
- .QueryInterface(Ci.nsIPrefBranch)
- .deleteBranch("mail.cloud_files.accounts");
- gMockCloudfileManager.unregister(kTestAccountType);
-}
-
-function create_dummy_account(aKey, aType, aDisplayName) {
- Services.prefs.setCharPref(
- "mail.cloud_files.accounts." + aKey + ".type",
- aType
- );
-
- Services.prefs.setCharPref(
- "mail.cloud_files.accounts." + aKey + ".displayName",
- aDisplayName
- );
-}
-
-function destroy_account(aKey) {
- Services.prefs.clearUserPref("mail.cloud_files.accounts." + aKey);
-}
-
-/**
- * Tests that we load the accounts and display them in the
- * account richlistbox in the correct order (by displayName,
- * case-insensitive)
- */
-function test_load_accounts_and_properly_order() {
- let prefTab = open_pref_tab("paneCompose", "compositionAttachmentsCategory");
-
- let richList = content_tab_e(prefTab, "cloudFileView");
- assert_equals(4, richList.itemCount, "Should be displaying 4 accounts");
-
- // Since we're sorting alphabetically by the displayName,
- // case-insensitive, the items should be ordered with the
- // following accountKeys:
- //
- // someKey3, someKey2, someKey4, someKey1
- const kExpected = ["someKey3", "someKey2", "someKey4", "someKey1"];
-
- for (let [index, expectedKey] of kExpected.entries()) {
- let item = richList.getItemAtIndex(index);
- assert_equals(expectedKey, item.value, "The account list is out of order");
- }
-
- close_pref_tab(prefTab);
-}
-
-/**
- * Tests that a link in the management pane is loaded in
- * a browser and not in the management pane.
- */
-test_external_link.__force_skip__ = true;
-function test_external_link() {
- gMockExtProtSvcReg.register();
-
- let prefTab = open_pref_tab("paneCompose", "compositionAttachmentsCategory");
- content_tab_e(prefTab, "cloudFileView").selectedIndex = 0;
-
- let iframe = content_tab_e(prefTab, "cloudFileSettingsWrapper")
- .firstElementChild;
- wait_for_frame_load(iframe, kSettingsWithLink + "?accountId=someKey3");
- mc.click(new elementslib.ID(iframe.contentDocument, "a"));
-
- let targetHref = "https://www.example.com/";
- mc.waitFor(
- () => gMockExtProtSvc.urlLoaded(targetHref),
- `Timed out waiting for the link ${targetHref} to be opened in the default browser.`
- );
- close_pref_tab(prefTab);
-
- gMockExtProtSvcReg.unregister();
-}
deleted file mode 100644
--- a/mail/test/mozmill/cloudfile/test-cloudfile-notifications.js
+++ /dev/null
@@ -1,540 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests that the cloudfile notifications work as they should.
- */
-
-"use strict";
-
-var {
- gMockFilePicker,
- gMockFilePickReg,
- select_attachments,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/AttachmentHelpers.jsm"
-);
-var {
- collectFiles,
- gMockCloudfileManager,
- MockCloudfileAccount,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/CloudfileHelpers.jsm"
-);
-var {
- add_attachments,
- add_cloud_attachments,
- close_compose_window,
- open_compose_new_mail,
-} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
-var { mc } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var {
- assert_notification_displayed,
- close_notification,
- wait_for_notification_to_stop,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/NotificationBoxHelpers.jsm"
-);
-var { gMockPromptService } = ChromeUtils.import(
- "resource://testing-common/mozmill/PromptHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var { cloudFileAccounts } = ChromeUtils.import(
- "resource:///modules/cloudFileAccounts.jsm"
-);
-
-var maxSize, oldInsertNotificationPref;
-
-var kOfferThreshold = "mail.compose.big_attachments.threshold_kb";
-var kInsertNotificationPref =
- "mail.compose.big_attachments.insert_notification";
-
-var kBoxId = "compose-notification-bottom";
-
-function setupModule(module) {
- gMockCloudfileManager.register();
- gMockFilePickReg.register();
-
- maxSize = Services.prefs.getIntPref(kOfferThreshold, 0) * 1024;
- oldInsertNotificationPref = Services.prefs.getBoolPref(
- kInsertNotificationPref
- );
- Services.prefs.setBoolPref(kInsertNotificationPref, true);
-}
-
-function teardownModule(module) {
- gMockCloudfileManager.unregister();
- gMockFilePickReg.unregister();
- Services.prefs.setBoolPref(
- kInsertNotificationPref,
- oldInsertNotificationPref
- );
-}
-
-/**
- * A helper function to assert that the Filelink offer notification is
- * either displayed or not displayed.
- *
- * @param aController the controller of the compose window to check.
- * @param aDisplayed true if the notification should be displayed, false
- * otherwise.
- */
-function assert_cloudfile_notification_displayed(aController, aDisplayed) {
- assert_notification_displayed(
- aController,
- kBoxId,
- "bigAttachment",
- aDisplayed
- );
-}
-
-/**
- * A helper function to assert that the Filelink upload notification is
- * either displayed or not displayed.
- *
- * @param aController the controller of the compose window to check.
- * @param aDisplayed true if the notification should be displayed, false
- * otherwise.
- */
-function assert_upload_notification_displayed(aController, aDisplayed) {
- assert_notification_displayed(
- aController,
- kBoxId,
- "bigAttachmentUploading",
- aDisplayed
- );
-}
-
-/**
- * A helper function to assert that the Filelink privacy warning notification
- * is either displayed or not displayed.
- *
- * @param aController the controller of the compose window to check.
- * @param aDisplayed true if the notification should be displayed, false
- * otherwise.
- */
-function assert_privacy_warning_notification_displayed(
- aController,
- aDisplayed
-) {
- assert_notification_displayed(
- aController,
- kBoxId,
- "bigAttachmentPrivacyWarning",
- aDisplayed
- );
-}
-
-/**
- * A helper function to close the Filelink upload notification.
- */
-function close_upload_notification(aController) {
- close_notification(aController, kBoxId, "bigAttachmentUploading");
-}
-
-/**
- * A helper function to close the Filelink privacy warning notification.
- */
-function close_privacy_warning_notification(aController) {
- close_notification(aController, kBoxId, "bigAttachmentPrivacyWarning");
-}
-
-function test_no_notification_for_small_file() {
- let cwc = open_compose_new_mail(mc);
- add_attachments(cwc, "http://www.example.com/1", 0);
- assert_cloudfile_notification_displayed(cwc, false);
-
- add_attachments(cwc, "http://www.example.com/2", 1);
- assert_cloudfile_notification_displayed(cwc, false);
-
- add_attachments(cwc, "http://www.example.com/3", 100);
- assert_cloudfile_notification_displayed(cwc, false);
-
- add_attachments(cwc, "http://www.example.com/4", 500);
- assert_cloudfile_notification_displayed(cwc, false);
-
- close_compose_window(cwc);
-}
-
-function test_notification_for_big_files() {
- let cwc = open_compose_new_mail(mc);
- add_attachments(cwc, "http://www.example.com/1", maxSize);
- assert_cloudfile_notification_displayed(cwc, true);
-
- add_attachments(cwc, "http://www.example.com/2", maxSize + 1000);
- assert_cloudfile_notification_displayed(cwc, true);
-
- add_attachments(cwc, "http://www.example.com/3", maxSize + 10000);
- assert_cloudfile_notification_displayed(cwc, true);
-
- add_attachments(cwc, "http://www.example.com/4", maxSize + 100000);
- assert_cloudfile_notification_displayed(cwc, true);
-
- close_compose_window(cwc);
-}
-
-function test_graduate_to_notification() {
- let cwc = open_compose_new_mail(mc);
- add_attachments(cwc, "http://www.example.com/1", maxSize - 100);
- assert_cloudfile_notification_displayed(cwc, false);
-
- add_attachments(cwc, "http://www.example.com/2", maxSize - 25);
- assert_cloudfile_notification_displayed(cwc, false);
-
- add_attachments(cwc, "http://www.example.com/3", maxSize);
- assert_cloudfile_notification_displayed(cwc, true);
-
- close_compose_window(cwc);
-}
-
-function test_no_notification_if_disabled() {
- Services.prefs.setBoolPref("mail.cloud_files.enabled", false);
- let cwc = open_compose_new_mail(mc);
-
- add_attachments(cwc, "http://www.example.com/1", maxSize);
- assert_cloudfile_notification_displayed(cwc, false);
-
- add_attachments(cwc, "http://www.example.com/2", maxSize + 1000);
- assert_cloudfile_notification_displayed(cwc, false);
-
- add_attachments(cwc, "http://www.example.com/3", maxSize + 10000);
- assert_cloudfile_notification_displayed(cwc, false);
-
- add_attachments(cwc, "http://www.example.com/4", maxSize + 100000);
- assert_cloudfile_notification_displayed(cwc, false);
-
- close_compose_window(cwc);
- Services.prefs.setBoolPref("mail.cloud_files.enabled", true);
-}
-
-/**
- * Tests that if we upload a single file, we get the link insertion
- * notification bar displayed (unless preffed off).
- */
-function test_link_insertion_notification_single() {
- gMockFilePicker.returnFiles = collectFiles(["./data/testFile1"], __file__);
- let provider = new MockCloudfileAccount();
- provider.init("aKey");
-
- let cwc = open_compose_new_mail(mc);
- add_cloud_attachments(cwc, provider);
-
- assert_upload_notification_displayed(cwc, true);
- close_upload_notification(cwc);
-
- Services.prefs.setBoolPref(kInsertNotificationPref, false);
- gMockFilePicker.returnFiles = collectFiles(["./data/testFile2"], __file__);
- add_cloud_attachments(cwc, provider);
-
- assert_upload_notification_displayed(cwc, false);
- Services.prefs.setBoolPref(kInsertNotificationPref, true);
-
- close_compose_window(cwc);
-}
-
-/**
- * Tests that if we upload multiple files, we get the link insertion
- * notification bar displayed (unless preffed off).
- */
-function test_link_insertion_notification_multiple() {
- gMockFilePicker.returnFiles = collectFiles(
- ["./data/testFile1", "./data/testFile2"],
- __file__
- );
- let provider = new MockCloudfileAccount();
- provider.init("aKey");
-
- let cwc = open_compose_new_mail(mc);
- add_cloud_attachments(cwc, provider);
-
- assert_upload_notification_displayed(cwc, true);
- close_upload_notification(cwc);
-
- Services.prefs.setBoolPref(kInsertNotificationPref, false);
- gMockFilePicker.returnFiles = collectFiles(
- ["./data/testFile3", "./data/testFile4"],
- __file__
- );
- add_cloud_attachments(cwc, provider);
-
- assert_upload_notification_displayed(cwc, false);
- Services.prefs.setBoolPref(kInsertNotificationPref, true);
-
- close_compose_window(cwc);
-}
-
-/**
- * Tests that the link insertion notification bar goes away even
- * if we hit an uploading error.
- */
-function test_link_insertion_goes_away_on_error() {
- gMockPromptService.register();
- gMockPromptService.returnValue = false;
- gMockFilePicker.returnFiles = collectFiles(
- ["./data/testFile1", "./data/testFile2"],
- __file__
- );
- let provider = new MockCloudfileAccount();
- provider.init("aKey");
-
- provider.uploadFile = function(aFile) {
- return new Promise((resolve, reject) => {
- cwc.window.setTimeout(() =>
- reject(cloudFileAccounts.constants.uploadErr)
- );
- }, 500);
- };
-
- let cwc = open_compose_new_mail(mc);
- add_cloud_attachments(cwc, provider, false);
-
- assert_upload_notification_displayed(cwc, true);
- wait_for_notification_to_stop(cwc, kBoxId, "bigAttachmentUploading");
-
- close_compose_window(cwc);
- gMockPromptService.unregister();
-}
-
-/**
- * Test that we do not show the Filelink offer notification if we convert
- * a Filelink back into a normal attachment.
- */
-function test_no_offer_on_conversion() {
- const kFiles = ["./data/testFile1", "./data/testFile2"];
- // Set the notification threshold to 0 to ensure that we get it.
- Services.prefs.setIntPref(kOfferThreshold, 0);
-
- // Insert some Filelinks...
- gMockFilePicker.returnFiles = collectFiles(kFiles, __file__);
- let provider = new MockCloudfileAccount();
- provider.init("someKey");
-
- // Override uploadFile to succeed instantaneously so that we don't have
- // to worry about waiting for the onStopRequest method being called
- // asynchronously.
- provider.uploadFile = function(aFile) {
- return Promise.resolve({
- id: 1,
- });
- };
-
- let cw = open_compose_new_mail();
- add_cloud_attachments(cw, provider, false);
-
- assert_cloudfile_notification_displayed(cw, false);
- // Now convert the file back into a normal attachment
- select_attachments(cw, 0);
- cw.window.convertSelectedToRegularAttachment();
-
- assert_cloudfile_notification_displayed(cw, false);
-
- close_compose_window(cw);
-
- // Now put the old threshold back.
- Services.prefs.setIntPref(kOfferThreshold, maxSize);
-}
-
-/**
- * Test that when we kick off an upload via the offer notification, then
- * the upload notification is shown.
- */
-function test_offer_then_upload_notifications() {
- const kFiles = ["./data/testFile1", "./data/testFile2"];
- // Set the notification threshold to 0 to ensure that we get it.
- Services.prefs.setIntPref(kOfferThreshold, 0);
-
- // We're going to add attachments to the attachmentbucket, and we'll
- // use the add_attachments helper function to do it. First, retrieve
- // some file URIs...
- let fileURIs = collectFiles(kFiles, __file__).map(
- file => Services.io.newFileURI(file).spec
- );
-
- // Create our mock provider
- let provider = new MockCloudfileAccount();
- provider.init("someKey");
-
- // Override uploadFile to succeed instantaneously so that we don't have
- // to worry about waiting for the onStopRequest method being called
- // asynchronously.
- provider.uploadFile = function(aFile) {
- return Promise.resolve({
- id: 1,
- });
- };
-
- let cw = open_compose_new_mail();
-
- // Attach the files, saying that each is 500 bytes large - which should
- // certainly trigger the offer.
- add_attachments(cw, fileURIs, [500, 500]);
- // Assert that the offer is displayed.
- assert_cloudfile_notification_displayed(cw, true);
- // Select both attachments in the attachmentbucket, and choose to convert
- // them.
- select_attachments(cw, 0, 1);
- // Convert them.
- cw.window.convertSelectedToCloudAttachment(provider);
-
- // The offer should now be gone...
- assert_cloudfile_notification_displayed(cw, false);
- // And the upload notification should be displayed.
- assert_upload_notification_displayed(cw, true);
-
- close_compose_window(cw);
-
- // Now put the old threshold back.
- Services.prefs.setIntPref(kOfferThreshold, maxSize);
-}
-
-/**
- * Test that when we first upload some files, we get the privacy warning
- * message. We should only get this the first time.
- */
-function test_privacy_warning_notification() {
- gMockPromptService.register();
- gMockPromptService.returnValue = false;
- gMockFilePicker.returnFiles = collectFiles(
- ["./data/testFile1", "./data/testFile2"],
- __file__
- );
- let provider = new MockCloudfileAccount();
- provider.init("aKey");
-
- provider.uploadFile = function(aFile, aListener) {
- return new Promise(resolve =>
- cwc.window.setTimeout(() => {
- resolve({
- id: 1,
- });
- }, 500)
- );
- };
- let cwc = open_compose_new_mail(mc);
- add_cloud_attachments(cwc, provider);
-
- assert_upload_notification_displayed(cwc, true);
- wait_for_notification_to_stop(cwc, kBoxId, "bigAttachmentUploading");
-
- // Assert that the warning is displayed.
- assert_privacy_warning_notification_displayed(cwc, true);
-
- // Close the privacy warning notification...
- close_privacy_warning_notification(cwc);
-
- // And now upload some more files. We shouldn't get the warning again.
- gMockFilePicker.returnFiles = collectFiles(
- ["./data/testFile3", "./data/testFile4"],
- __file__
- );
- add_cloud_attachments(cwc, provider, false);
- assert_privacy_warning_notification_displayed(cwc, false);
-
- close_compose_window(cwc);
- gMockPromptService.unregister();
-}
-
-/**
- * Test that the privacy warning notification does not persist when closing
- * and re-opening a compose window.
- */
-function test_privacy_warning_notification_no_persist() {
- gMockPromptService.register();
- gMockPromptService.returnValue = false;
- gMockFilePicker.returnFiles = collectFiles(
- ["./data/testFile1", "./data/testFile2"],
- __file__
- );
- let provider = new MockCloudfileAccount();
- provider.init("aKey");
-
- provider.uploadFile = function(aFile, aListener) {
- return new Promise(resolve =>
- cwc.window.setTimeout(() => {
- resolve({
- id: 1,
- });
- }, 500)
- );
- };
- let cwc = open_compose_new_mail(mc);
- add_cloud_attachments(cwc, provider, false);
-
- assert_upload_notification_displayed(cwc, true);
- wait_for_notification_to_stop(cwc, kBoxId, "bigAttachmentUploading");
-
- // Assert that the warning is displayed.
- assert_privacy_warning_notification_displayed(cwc, true);
-
- // Close the compose window
- close_compose_window(cwc);
-
- // Open a new compose window
- cwc = open_compose_new_mail(mc);
-
- // We shouldn't be displaying the privacy warning.
- assert_privacy_warning_notification_displayed(cwc, false);
-
- close_compose_window(cwc);
- gMockPromptService.unregister();
-}
-
-/**
- * Test that if we close the privacy warning in a composer, it will still
- * spawn in a new one.
- */
-function test_privacy_warning_notification_open_after_close() {
- gMockPromptService.register();
- gMockPromptService.returnValue = false;
- gMockFilePicker.returnFiles = collectFiles(
- ["./data/testFile1", "./data/testFile2"],
- __file__
- );
- let provider = new MockCloudfileAccount();
- provider.init("aKey");
-
- provider.uploadFile = function(aFile, aListener) {
- return new Promise(resolve =>
- cwc.window.setTimeout(() => {
- resolve({
- id: 1,
- });
- }, 500)
- );
- };
- let cwc = open_compose_new_mail(mc);
- add_cloud_attachments(cwc, provider, false);
-
- assert_upload_notification_displayed(cwc, true);
- wait_for_notification_to_stop(cwc, kBoxId, "bigAttachmentUploading");
-
- // Assert that the warning is displayed.
- assert_privacy_warning_notification_displayed(cwc, true);
-
- // Close the privacy warning notification...
- close_privacy_warning_notification(cwc);
-
- close_compose_window(cwc);
-
- // Open a new compose window
- cwc = open_compose_new_mail(mc);
-
- gMockFilePicker.returnFiles = collectFiles(
- ["./data/testFile3", "./data/testFile4"],
- __file__
- );
- add_cloud_attachments(cwc, provider);
-
- assert_upload_notification_displayed(cwc, true);
- wait_for_notification_to_stop(cwc, kBoxId, "bigAttachmentUploading");
-
- // Assert that the privacy warning notification is displayed again.
- assert_privacy_warning_notification_displayed(cwc, true);
-
- close_compose_window(cwc);
- gMockPromptService.unregister();
-}
deleted file mode 100644
--- a/mail/test/mozmill/composition/attachment.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-"Attachment is the great fabricator of illusions; reality can be attained only
- by someone who is detached."
-
- -- Simone Weil
deleted file mode 100644
--- a/mail/test/mozmill/composition/base64-encoded-msg.eml
+++ /dev/null
@@ -1,11 +0,0 @@
-Message-ID: <4877F4BB.3060507@example.org>
-Date: Fri, 11 Jul 2008 20:03:07 -0400
-From: Joe <joe@example.org>
-MIME-Version: 1.0
-To: Jane <jane@example.org>
-Subject: base64 content
-Content-Type: text/plain; charset=ISO-8859-1
-Content-Transfer-Encoding: base64
-
-WW91IGhhdmUgZGVjb2RlZCB0aGlzIHRleHQgZnJvbSBiYXNlNjQu
-
deleted file mode 100644
--- a/mail/test/mozmill/composition/base64-with-whitespace.eml
+++ /dev/null
@@ -1,46 +0,0 @@
-Date: Tue, 31 Aug 2018 16:33:00 +0200
-From: From <from@example.com>
-To: To <to@example.com>
-Subject: Bug 1487421 - BASE64 MIME body and attachment with empty lines in between
-MIME-Version: 1.0
-Message-ID: <1dcZe4@example.com>
-Content-Type: multipart/mixed;
- boundary="------------DA562B250842CC7332F16476"
-
-This is a multi-part message in MIME format.
---------------DA562B250842CC7332F16476
-Content-Type: text/plain; charset=utf-8
-Content-Transfer-Encoding: base64
-
-YWJj
-
-ZG
-
-V
-
-mZ2hpamtsbW
-
-5vcHFyc3R1dnd4
-
-eXo=
-
---------------DA562B250842CC7332F16476
-Content-Type: text/plain; charset=utf-8
-Content-Transfer-Encoding: base64
-Content-Disposition: attachment;
- filename="test.txt"
-
-YWJj
-
-ZG
-
-V
-
-mZ2hpamtsbW
-
-5vcHFyc3R1dnd4
-
-eXo=
-
---------------DA562B250842CC7332F16476--
-
deleted file mode 100644
--- a/mail/test/mozmill/composition/body-greek.eml
+++ /dev/null
@@ -1,9 +0,0 @@
-From: test <test@example.com>
-Subject: test reply to ISO-8859-7 encoded message
-To: test2 <test2@example.com>
-Date: Sat, 27 Feb 2016 17:11:45 +0100
-MIME-Version: 1.0
-Content-Type: text/plain; charset=ISO-8859-7
-Content-Transfer-Encoding: quoted-printable
-
-Here comes some Greek text: =CA=E1=EB=E7=F3=F0=DD=F1=E1
deleted file mode 100644
--- a/mail/test/mozmill/composition/body-utf16.eml
+++ /dev/null
@@ -1,10 +0,0 @@
-From: test <test@example.com>
-Subject: test reply to UTF-16 encoded message
-To: test2 <test2@example.com>
-Date: Sat, 27 Feb 2016 17:11:45 +0100
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-16LE;
-Content-Transfer-Encoding: base64
-
-//5IAGkAIABNAGEAZwBuAHUAcwAsACAAaABlAHIAZQAgAGEAIABiAGUAdAB0AGUAcgAgAFUA
-VABGAC0AMQA2ACAAZQBuAGMAbwBkAGUAZAAgAG0AYQBpAGwALgA=
deleted file mode 100644
--- a/mail/test/mozmill/composition/charset-cp932.eml
+++ /dev/null
@@ -1,11 +0,0 @@
-Date: Tue, 4 Dec 2018 15:23:22 +0900
-From: from@example.org
-Subject: =?cp932?Q?=82=b1=82=b1=82=c9=96=7b=95=b6=82=aa=82=ab=82=dc=82=b7=81=42?=
-To: to@example.org
-Message-Id: <424F4F74-05B4-4575-8B0D-473334183C69@example.org>
-Mime-Version: 1.0 (1.0)
-Content-Type: text/plain; charset=cp932
-Content-Transfer-Encoding: 8bit
-
-‚±‚±‚É–{•¶‚ª‚«‚Ü‚·B
-
deleted file mode 100644
--- a/mail/test/mozmill/composition/content-utf8-alt-rel.eml
+++ /dev/null
@@ -1,46 +0,0 @@
-From: test <test@example.com>
-Subject: test multipart, alternative first
-To: test2 <test2@example.com>
-Date: Sat, 27 Feb 2016 17:11:45 +0100
-MIME-Version: 1.0
-Content-Type: multipart/alternative;
- boundary="------------alternative"
-
-This is a multi-part message in MIME format.
---------------alternative
-Content-Type: text/plain; charset=UTF-8; format=flowed
-Content-Transfer-Encoding: 8bit
-
-áóúäöüß
-
---------------alternative
-Content-Type: multipart/related;
- boundary="------------related"
-
-
---------------related
-Content-Type: text/html; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-<html attr>
- <!-- This also needs to work when the html tag has an attribute -->
- <head>
- <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
- </head>
- <body bgcolor="#FFFFFF" text="#000000">
- áóúäöüß<br>
- <img src="cid:part1" alt=""><br>
- </body>
-</html>
-
---------------related
-Content-Type: image/png
-Content-Transfer-Encoding: base64
-Content-ID: <part1>
-
-iVBORw0KGgoAAAANSUhEUgAAAAYAAAALCAIAAADTMGvBAAAAEUlEQVQImWPgsi5DQwxDWggA
-lCEwN+YGfiYAAAAASUVORK5CYII=
---------------related--
-
---------------alternative--
-
deleted file mode 100644
--- a/mail/test/mozmill/composition/content-utf8-alt-rel2.eml
+++ /dev/null
@@ -1,46 +0,0 @@
-From: test <test@example.com>
-Subject: test multipart, alternative first
-To: test2 <test2@example.com>
-Date: Sat, 27 Feb 2016 17:11:45 +0100
-MIME-Version: 1.0
-Content-Type: multipart/alternative;
- boundary="------------alternative"
-
-This is a multi-part message in MIME format.
---------------alternative
-Content-Type: text/plain; charset=UTF-8; format=flowed
-Content-Transfer-Encoding: 8bit
-
-áóúäöüß
-
---------------alternative
-Content-Type: multipart/related;
- boundary="------------related"
-
-
---------------related
-Content-Type: text/html; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-áóúäöüß<br>
-<html>
- <!-- This also needs to work when there is content before the html tag :-( -->
- <head>
- <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
- </head>
- <body bgcolor="#FFFFFF" text="#000000">
- <img src="cid:part1" alt=""><br>
- </body>
-</html>
-
---------------related
-Content-Type: image/png
-Content-Transfer-Encoding: base64
-Content-ID: <part1>
-
-iVBORw0KGgoAAAANSUhEUgAAAAYAAAALCAIAAADTMGvBAAAAEUlEQVQImWPgsi5DQwxDWggA
-lCEwN+YGfiYAAAAASUVORK5CYII=
---------------related--
-
---------------alternative--
-
deleted file mode 100644
--- a/mail/test/mozmill/composition/content-utf8-rel-alt.eml
+++ /dev/null
@@ -1,40 +0,0 @@
-From: test <test@example.com>
-Subject: test multipart, related first
-To: test2 <test2@example.com>
-Date: Sat, 27 Feb 2016 17:11:45 +0100
-MIME-Version: 1.0
-Content-Type: multipart/related;
- boundary="------------related"
-
---------------related
-Content-Type: multipart/alternative;
- boundary="------------alternative"
-Content-Type: text/plain; charset=UTF-8; format=flowed
-Content-Transfer-Encoding: 8bit
-
-áóúäöüß
-
---------------alternative
-Content-Type: text/html; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
- <!-- This also needs to work when there is no html tag -->
- <head>
- <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
- </head>
- <body bgcolor="#FFFFFF" text="#000000">
- áóúäöüß<br>
- <img src="cid:part1" alt=""><br>
- </body>
-
---------------alternative
-
---------------related
-Content-Type: image/png
-Content-Transfer-Encoding: base64
-Content-ID: <part1>
-
-iVBORw0KGgoAAAANSUhEUgAAAAYAAAALCAIAAADTMGvBAAAAEUlEQVQImWPgsi5DQwxDWggA
-lCEwN+YGfiYAAAAASUVORK5CYII=
-
---------------related--
deleted file mode 100644
--- a/mail/test/mozmill/composition/content-utf8-rel-only.eml
+++ /dev/null
@@ -1,32 +0,0 @@
-From: test <test@example.com>
-Subject: test HTML related only
-To: test2 <test2@example.com>
-Date: Sat, 27 Feb 2016 17:11:45 +0100
-MIME-Version: 1.0
-Content-Type: multipart/related;
- boundary="------------related"
-
-This is a multi-part message in MIME format.
---------------related
-Content-Type: text/html; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-<html>
- <head>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8">
- </head>
- <body bgcolor="#FFFFFF" text="#000000">
- áóúäöüß<br>
- <img src="cid:part1" id="cidImage" width="10" height="10" alt="">
- <img src="cid:part1" crossorigin="anonymous" id="cidImageOrigin" width="20" height="20" alt="">
- </body>
-</html>
-
---------------related
-Content-Type: image/png
-Content-Transfer-Encoding: base64
-Content-ID: <part1>
-
-iVBORw0KGgoAAAANSUhEUgAAAAYAAAALCAIAAADTMGvBAAAAEUlEQVQImWPgsi5DQwxDWggA
-lCEwN+YGfiYAAAAASUVORK5CYII=
---------------related--
deleted file mode 100644
--- a/mail/test/mozmill/composition/feed-message.eml
+++ /dev/null
@@ -1,26 +0,0 @@
-From - Fri, 27 Jan 2017 00:19:08 GMT
-X-Mozilla-Status: 0041
-X-Mozilla-Status2: 00000000
-X-Mozilla-Keys:
-Received: by localhost; Fri, 27 Jan 2017 07:52:26 +0100
-Date: Fri, 27 Jan 2017 00:19:08 GMT
-Message-Id: <http://www.selenic.com/mercurial/#changeset-c11fe7c58837ebf4266357d1f31896c7cc4a49b9@localhost.localdomain>
-From: john@example.com
-MIME-Version: 1.0
-Subject: Changeset c11fe7c58837ebf4266357d1f31896c7cc4a49b9
-Content-Transfer-Encoding: 8bit
-Content-Base: http://hg.mozilla.org/mozilla-central/rev/c11fe7c58837ebf4266357d1f31896c7cc4a49b9
-Content-Type: text/html; charset=UTF-8
-
-<html>
- <head>
- <title>Changeset c11fe7c58837ebf4266357d1f31896c7cc4a49b9</title>
- <base href="http://hg.mozilla.org/mozilla-central/pushlog">
- </head>
- <body id="msgFeedSummaryBody" selected="false">
- <div xmlns="http://www.w3.org/1999/xhtml">
- <ul class="filelist"><li class="file">modules/libpref/init/all.js</li><li class="file">netwerk/base/nsIOService.cpp</li><li class="file">netwerk/base/nsIOService.h</li><li class="file">We like using linefeeds only.</li></ul>
- </div>
- </body>
-</html>
-
deleted file mode 100644
--- a/mail/test/mozmill/composition/format-flowed.eml
+++ /dev/null
@@ -1,12 +0,0 @@
-To: test1@test.invalid
-From: test2@test.invalid
-Subject: test format flowed reply
-Date: Tue, 27 Sep 2016 13:00:40 +0200
-MIME-Version: 1.0
-Content-Type: text/plain; charset=windows-1252; format=flowed
-Content-Language: en-US
-Content-Transfer-Encoding: 7bit
-
-first first first first first text text text text text text text text
-text text text text text text text text text text text text text text
-last last last last last last last last last last last last last last
deleted file mode 100644
--- a/mail/test/mozmill/composition/format1-altering.eml
+++ /dev/null
@@ -1,21 +0,0 @@
-Message-ID: <11111.11111@example.invalid>
-Date: Sun, 18 May 2014 22:31:12 +0200
-MIME-Version: 1.0
-To: test@test.invalid
-Content-Type: text/html; charset=utf-8
-Content-Transfer-Encoding: 7bit
-
-<html>
- <head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8">
- <title>title</title>
- </head>
- <body bgcolor="#FFFFFF" text="#000000">
- <h1>heading</h1>
- <hr>
- <pre>
- Pre line 1
- Pre line 2
- </pre>
- </body>
-</html>
deleted file mode 100644
--- a/mail/test/mozmill/composition/format1-plain.eml
+++ /dev/null
@@ -1,22 +0,0 @@
-Message-ID: <11111.11111@example.invalid>
-Date: Sun, 18 May 2014 22:31:12 +0200
-MIME-Version: 1.0
-To: test@test.invalid
-Content-Type: text/html; charset=utf-8
-Content-Transfer-Encoding: 7bit
-
-<html>
- <head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8">
- <title>title</title>
- </head>
- <body bgcolor="#FFFFFF" text="#000000">
- Line 1<br>
-<p>
- Line 2
-</p>
- <pre class="moz-signature" cols="72">--
- Signature block
- </pre>
- </body>
-</html>
deleted file mode 100644
--- a/mail/test/mozmill/composition/format2-style-attr.eml
+++ /dev/null
@@ -1,37 +0,0 @@
-Message-ID: <22222222.2222222@example.invalid>
-Date: Sun, 17 Jun 2012 09:42:45 +0200
-From: John Doe
-MIME-Version: 1.0
-Subject: Testcase - style attribute
-Content-Type: text/html; charset=ISO-8859-1
-Content-Transfer-Encoding: 7bit
-
-<html>
- <head>
- <meta http-equiv="content-type" content="text/html;
- charset=ISO-8859-1">
- </head>
- <body bgcolor="#FFFFFF" text="#000000">
- *** This text is "Variable Width" ***<br>
- <br>
- <a title="Get the best mailer now! (Caveat: neglected bird with lots
- of bugs)" style="float: right; background-color: blue; font-size:
- 18px; text-decoration: none; color: white; padding-top: 90px;
- padding-bottom: 90px; padding-right: 50px; padding-left: 50px;"
- href="http://www.getthunderbird.com">http://www.getthunderbird.com</a><a
- title="Get the best browser now!" style="float: right;
- background-color: orangered; font-size: 18px; text-decoration:
- none; color: white; padding-top: 90px; padding-bottom: 90px;
- padding-right: 50px; padding-left: 50px;"
- href="http://www.getfirefox.com">http://www.getfirefox.com</a>Lorem
- ipsum
- dolor sit amet, consectetur adipiscing elit. Vestibulum
- velit purus, egestas eu commodo ac, imperdiet pretium sem. Nulla
- pulvinar commodo rutrum. Duis feugiat facilisis libero, id fermentum
- neque molestie vel. Praesent vel nisi metus, a aliquam tellus. Cras
- in
- <pre style="color:blue;background-color:yellow;text-align:center;">
- Vivamus accumsan bibendum arcu nec egestas. Suspendisse potenti.
- </pre>
- </body>
-</html>
deleted file mode 100644
--- a/mail/test/mozmill/composition/format3-style-tag.eml
+++ /dev/null
@@ -1,31 +0,0 @@
-Message-ID: <33333.33333@example.invalid>
-Date: Sun, 17 Jun 2012 09:42:45 +0200
-MIME-Version: 1.0
-Subject: <style> element
-Content-Type: text/html; charset=ISO-8859-1
-Content-Transfer-Encoding: 7bit
-
-<html>
-<head>
-
-<style type="text/css">
-<!--
-body {
-font-size:11.0pt;
-font-family:"Calibri","sans-serif";
-}
-ul, ol, blockquote {
-margin: 0px 0px;
-}
--->
-</style>
-
-</head><body>
-
-Type text here
-
-<div id="imageholder">
-
-</div>
-</body>
-</html>
deleted file mode 100644
--- a/mail/test/mozmill/composition/long-html-line.eml
+++ /dev/null
@@ -1,16 +0,0 @@
-From: "Long line writer" <email@longline.invalid>
-To: <user@example.com>
-Subject: Long HTML line
-Date: Wed, 10 Feb 2016 16:45:36 -0600
-MIME-Version: 1.0
-Content-Type: text/html;
- charset="us-ascii"
-Content-Transfer-Encoding: 7bit
-
-<!DOCTYPE html>
-<html>
-<body>
-
-We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. We like writing long lines. This is 998 long.
-
- </body>
deleted file mode 100644
--- a/mail/test/mozmill/composition/mime-encoded-subject.eml
+++ /dev/null
@@ -1,16 +0,0 @@
-Return-Path: <homer@example.com>
-Received: from smtp.example.com (smtpu [10.0.0.52])
- by storage (Cyrus v2.3.7-Invoca-RPM-2.3.7-1.1) with LMTPA;
- Mon, 26 Dec 2011 20:49:16 +0200
-Message-ID: <4EF8C1A5.1060708@example.com>
-Date: Mon, 26 Dec 2011 20:49:09 +0200
-From: Homer <homer@example.com>
-MIME-Version: 1.0
-To: Marge <marge@example.com>
-Subject: =?UTF-8?B?4oiAYeKIikE=?=
-Content-Type: text/plain; charset=UTF-8; format=flowed
-Content-Transfer-Encoding: 7bit
-
-Because they're stupid, that's why. That's why everybody does everything!
-
- -Homer
deleted file mode 100644
--- a/mail/test/mozmill/composition/multipart-charset.eml
+++ /dev/null
@@ -1,24 +0,0 @@
-From: test <test@example.com>
-Subject: test multipart mixed, attachment with different charset
-To: test2 <test2@example.com>
-Date: Sat, 27 Feb 2016 17:11:45 +0100
-MIME-Version: 1.0
-Content-Type: multipart/mixed;
- boundary="boundary"
-
-This is a multi-part message in MIME format.
---boundary
-Content-Type: text/plain; charset=EUC-KR; format=flowed
-Content-Transfer-Encoding: 7bit
-
-Hi there.
-
---boundary
-Content-Type: text/plain; charset=KOI8-R;
- name="attachment.tmx"
-Content-Transfer-Encoding: 7bit
-Content-Disposition: attachment;
- filename="attachment.tmx"
-
-Just some text.
---boundary--
deleted file mode 100644
index aac56e25465a4fa6a2bcf4f87f2fb662bea20bbe..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
--- a/mail/test/mozmill/composition/test-address-widgets.js
+++ /dev/null
@@ -1,175 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests proper enabling of addressing widgets.
- */
-
-"use strict";
-
-var { close_compose_window, open_compose_new_mail } = ChromeUtils.import(
- "resource://testing-common/mozmill/ComposeHelpers.jsm"
-);
-var {
- assert_equals,
- assert_false,
- assert_not_equals,
- assert_true,
- be_in_folder,
- FAKE_SERVER_HOSTNAME,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var { fixIterator } = ChromeUtils.import(
- "resource:///modules/iteratorUtils.jsm"
-);
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-var cwc = null; // compose window controller
-var accountPOP3 = null;
-var accountNNTP = null;
-var originalAccountCount;
-
-function setupModule(module) {
- // Ensure we're in the tinderbox account as that has the right identities set
- // up for this test.
- let server = MailServices.accounts.FindServer(
- "tinderbox",
- FAKE_SERVER_HOSTNAME,
- "pop3"
- );
- accountPOP3 = MailServices.accounts.FindAccountForServer(server);
-
- // There may be pre-existing accounts from other tests.
- originalAccountCount = MailServices.accounts.allServers.length;
-}
-
-function teardownModule(module) {}
-
-/**
- * Check if the address type items are in the wished state.
- *
- * @param aItemsEnabled List of item values that should be enabled (uncollapsed).
- */
-function check_address_types_state(aItemsEnabled) {
- let addr_types = cwc.e("addressingWidgetLabels").querySelectorAll("label");
- for (let item of addr_types) {
- assert_true(item.collapsed != aItemsEnabled.includes(item.id));
- }
-}
-
-/**
- * With only a POP3 account, no News related address types should be enabled.
- */
-function check_mail_address_types() {
- check_address_types_state(["addr_to", "addr_cc", "addr_reply", "addr_bcc"]);
-}
-
-/**
- * With a NNTP account, all address types should be enabled.
- */
-function check_nntp_address_types() {
- check_address_types_state([
- "addr_to",
- "addr_cc",
- "addr_reply",
- "addr_bcc",
- "addr_newsgroups",
- "addr_followup",
- ]);
-}
-
-function add_NNTP_account() {
- // Create a NNTP server
- let nntpServer = MailServices.accounts
- .createIncomingServer(null, "example.nntp.invalid", "nntp")
- .QueryInterface(Ci.nsINntpIncomingServer);
-
- let identity = MailServices.accounts.createIdentity();
- identity.email = "tinderbox2@example.invalid";
-
- accountNNTP = MailServices.accounts.createAccount();
- accountNNTP.incomingServer = nntpServer;
- accountNNTP.addIdentity(identity);
- // Now there should be 1 more account.
- assert_equals(
- MailServices.accounts.allServers.length,
- originalAccountCount + 1
- );
-}
-
-function remove_NNTP_account() {
- // Remove our NNTP account to leave the profile clean.
- MailServices.accounts.removeAccount(accountNNTP);
- // There should be only the original accounts left.
- assert_equals(MailServices.accounts.allServers.length, originalAccountCount);
-}
-
-/**
- * Bug 399446 & bug 922614
- * Test that the allowed address types depend on the account type
- * we are sending from.
- */
-function test_address_types() {
- // Be sure there is no NNTP account yet.
- for (let account of fixIterator(
- MailServices.accounts.accounts,
- Ci.nsIMsgAccount
- )) {
- assert_not_equals(
- account.incomingServer.type,
- "nntp",
- "There is a NNTP account existing unexpectedly"
- );
- }
-
- // Open compose window on the existing POP3 account.
- be_in_folder(accountPOP3.incomingServer.rootFolder);
- cwc = open_compose_new_mail();
- check_mail_address_types();
- close_compose_window(cwc);
-
- add_NNTP_account();
-
- // From now on, we should always get all possible address types offered,
- // regardless of which account is used of composing (bug 922614).
- be_in_folder(accountNNTP.incomingServer.rootFolder);
- cwc = open_compose_new_mail();
- check_nntp_address_types();
- close_compose_window(cwc);
-
- // Now try the same accounts but choosing them in the From dropdown
- // inside compose window.
- be_in_folder(accountPOP3.incomingServer.rootFolder);
- cwc = open_compose_new_mail();
- check_nntp_address_types();
-
- let NNTPidentity = accountNNTP.defaultIdentity.key;
- cwc.click(cwc.eid("msgIdentity"));
- cwc.click_menus_in_sequence(cwc.e("msgIdentityPopup"), [
- { identitykey: NNTPidentity },
- ]);
- check_nntp_address_types();
-
- // Switch back to the POP3 account.
- let POP3identity = accountPOP3.defaultIdentity.key;
- cwc.click(cwc.eid("msgIdentity"));
- cwc.click_menus_in_sequence(cwc.e("msgIdentityPopup"), [
- { identitykey: POP3identity },
- ]);
- check_nntp_address_types();
-
- close_compose_window(cwc);
-
- remove_NNTP_account();
-
- // Now the NNTP account is lost, so we should be back to mail only addressees.
- be_in_folder(accountPOP3.incomingServer.rootFolder);
- cwc = open_compose_new_mail();
- check_mail_address_types();
- close_compose_window(cwc);
-}
deleted file mode 100644
--- a/mail/test/mozmill/composition/test-attachment-reminder.js
+++ /dev/null
@@ -1,846 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests that the attachment reminder works properly.
- */
-
-"use strict";
-
-var {
- add_attachments,
- close_compose_window,
- open_compose_new_mail,
- setup_msg_contents,
- wait_for_compose_window,
-} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
-var {
- assert_equals,
- assert_true,
- be_in_folder,
- get_special_folder,
- mc,
- press_delete,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { delete_all_existing } = ChromeUtils.import(
- "resource://testing-common/mozmill/KeyboardHelpers.jsm"
-);
-var {
- assert_notification_displayed,
- check_notification_displayed,
- get_notification_button,
- wait_for_notification_to_show,
- wait_for_notification_to_stop,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/NotificationBoxHelpers.jsm"
-);
-var {
- close_window,
- plan_for_modal_dialog,
- plan_for_new_window,
- plan_for_window_close,
- wait_for_modal_dialog,
- wait_for_window_close,
- wait_for_window_focused,
-} = ChromeUtils.import("resource://testing-common/mozmill/WindowHelpers.jsm");
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-var kBoxId = "compose-notification-bottom";
-var kNotificationId = "attachmentReminder";
-var kReminderPref = "mail.compose.attachment_reminder";
-var gDrafts;
-var gOutbox;
-
-function setupModule(module) {
- gDrafts = get_special_folder(Ci.nsMsgFolderFlags.Drafts, true);
- gOutbox = get_special_folder(Ci.nsMsgFolderFlags.Queue);
-
- assert_true(Services.prefs.getBoolPref(kReminderPref));
-}
-
-/**
- * Check if the attachment reminder bar is in the wished state.
- *
- * @param aCwc A compose window controller.
- * @param aShown True for expecting the bar to be shown, false otherwise.
- *
- * @return If the bar is shown, return the notification object.
- */
-function assert_automatic_reminder_state(aCwc, aShown) {
- return assert_notification_displayed(aCwc, kBoxId, kNotificationId, aShown);
-}
-
-/**
- * Waits for the attachment reminder bar to change into the wished state.
- *
- * @param aCwc A compose window controller.
- * @param aShown True for waiting for the bar to be shown,
- * false for waiting for it to be hidden.
- * @param aDelay Set to true to sleep a while to give the notification time
- * to change. This is used if the state is already what we want
- * but we expect it could change in a short while.
- */
-function wait_for_reminder_state(aCwc, aShown, aDelay = false) {
- const notificationSlackTime = 5000;
-
- if (aShown) {
- if (aDelay) {
- aCwc.sleep(notificationSlackTime);
- }
- // This waits up to 30 seconds for the notification to appear.
- wait_for_notification_to_show(aCwc, kBoxId, kNotificationId);
- } else if (check_notification_displayed(aCwc, kBoxId, kNotificationId)) {
- // This waits up to 30 seconds for the notification to disappear.
- wait_for_notification_to_stop(aCwc, kBoxId, kNotificationId);
- } else {
- // This waits 5 seconds during which the notification must not appear.
- aCwc.sleep(notificationSlackTime);
- assert_automatic_reminder_state(aCwc, false);
- }
-}
-
-/**
- * Check whether the manual reminder is in the proper state.
- *
- * @param aCwc A compose window controller.
- * @param aChecked Whether the reminder should be enabled.
- */
-function assert_manual_reminder_state(aCwc, aChecked) {
- const remindCommand = "cmd_remindLater";
- assert_equals(
- aCwc.e("button-attachPopup_remindLaterItem").getAttribute("command"),
- remindCommand
- );
-
- let checkedValue = aChecked ? "true" : "false";
- assert_equals(aCwc.e(remindCommand).getAttribute("checked"), checkedValue);
-}
-
-/**
- * Returns the keywords string currently shown in the notification message.
- *
- * @param aCwc A compose window controller.
- */
-function get_reminder_keywords(aCwc) {
- assert_automatic_reminder_state(aCwc, true);
- let nBox = aCwc.e(kBoxId).querySelector(".notificationbox-stack")
- ._notificationBox;
- let notification = nBox.getNotificationWithValue(kNotificationId);
- return notification
- .querySelector("#attachmentKeywords")
- .getAttribute("value");
-}
-
-/**
- * Test that the attachment reminder works, in general.
- */
-function test_attachment_reminder_appears_properly() {
- let cwc = open_compose_new_mail();
-
- // There should be no notification yet.
- assert_automatic_reminder_state(cwc, false);
-
- setup_msg_contents(
- cwc,
- "test@example.org",
- "Testing automatic reminder!",
- "Hello! "
- );
-
- // Give the notification time to appear. It shouldn't.
- wait_for_reminder_state(cwc, false);
-
- cwc.type(cwc.eid("content-frame"), "Seen this cool attachment?");
-
- // Give the notification time to appear. It should now.
- wait_for_reminder_state(cwc, true);
-
- // The manual reminder should be disabled yet.
- assert_manual_reminder_state(cwc, false);
-
- // Click ok to be notified on send if no attachments are attached.
- cwc.click(
- new elementslib.Elem(
- cwc.e(kBoxId).querySelector('button[label="Remind Me Later"]')
- )
- );
- wait_for_reminder_state(cwc, false);
-
- // The manual reminder should be enabled now.
- assert_manual_reminder_state(cwc, true);
-
- // Now try to send, make sure we get the alert.
- plan_for_modal_dialog("commonDialogWindow", click_oh_i_did);
- cwc.click(cwc.eid("button-send"));
- wait_for_modal_dialog("commonDialogWindow");
-
- // After confirming the reminder the menuitem should get disabled.
- assert_manual_reminder_state(cwc, false);
-
- close_compose_window(cwc);
-}
-
-/**
- * Test that the alert appears normally, but not after closing the
- * notification.
- */
-function test_attachment_reminder_dismissal() {
- let cwc = open_compose_new_mail();
-
- // There should be no notification yet.
- assert_automatic_reminder_state(cwc, false);
-
- setup_msg_contents(
- cwc,
- "test@example.org",
- "popping up, eh?",
- "Hi there, remember the attachment! " +
- "Yes, there is a file test.doc attached! " +
- "Do check it, test.doc is a nice attachment."
- );
-
- // Give the notification time to appear.
- wait_for_reminder_state(cwc, true);
-
- assert_equals(get_reminder_keywords(cwc), "test.doc, attachment, attached");
-
- // We didn't click the "Remind Me Later" - the alert should pop up
- // on send anyway.
- plan_for_modal_dialog("commonDialogWindow", click_oh_i_did);
- cwc.click(cwc.eid("button-send"));
- wait_for_modal_dialog("commonDialogWindow");
-
- let notification = assert_automatic_reminder_state(cwc, true);
-
- notification.close();
- assert_automatic_reminder_state(cwc, false);
-
- click_send_and_handle_send_error(cwc);
-
- close_compose_window(cwc);
-}
-
-/**
- * Bug 938829
- * Check that adding an attachment actually hides the notification.
- */
-function test_attachment_reminder_with_attachment() {
- let cwc = open_compose_new_mail();
-
- // There should be no notification yet.
- assert_automatic_reminder_state(cwc, false);
-
- setup_msg_contents(
- cwc,
- "test@example.org",
- "Testing automatic reminder!",
- "Hello! We will have a real attachment here."
- );
-
- // Give the notification time to appear. It should.
- wait_for_reminder_state(cwc, true);
-
- // Add an attachment.
- let file = Services.dirsvc.get("ProfD", Ci.nsIFile);
- file.append("panacea.dat");
- assert_true(
- file.exists(),
- "The required file panacea.dat was not found in the profile."
- );
- let attachment = [cwc.window.FileToAttachment(file)];
- cwc.window.AddAttachments(attachment);
-
- // The notification should hide.
- wait_for_reminder_state(cwc, false);
-
- // Add some more text with keyword so the automatic notification
- // could potentially show up.
- setup_msg_contents(cwc, "", "", " Yes, there is a file attached!");
- // Give the notification time to appear. It shouldn't.
- wait_for_reminder_state(cwc, false);
-
- cwc.window.RemoveAllAttachments();
-
- // After removing the attachment, notification should come back
- // with all the keywords, even those input while having an attachment.
- wait_for_reminder_state(cwc, true);
- assert_equals(get_reminder_keywords(cwc), "attachment, attached");
-
- close_compose_window(cwc);
-}
-
-/**
- * Test that the mail.compose.attachment_reminder_aggressive pref works.
- */
-function test_attachment_reminder_aggressive_pref() {
- const kPref = "mail.compose.attachment_reminder_aggressive";
- Services.prefs.setBoolPref(kPref, false);
-
- let cwc = open_compose_new_mail();
-
- // There should be no notification yet.
- assert_automatic_reminder_state(cwc, false);
-
- setup_msg_contents(
- cwc,
- "test@example.org",
- "aggressive?",
- "Check this attachment!"
- );
-
- wait_for_reminder_state(cwc, true);
- click_send_and_handle_send_error(cwc);
-
- close_compose_window(cwc);
-
- // Now reset the pref back to original value.
- if (Services.prefs.prefHasUserValue(kPref)) {
- Services.prefs.clearUserPref(kPref);
- }
-}
-
-/**
- * Test that clicking "No, Send Now" in the attachment reminder alert
- * works.
- */
-function test_no_send_now_sends() {
- let cwc = open_compose_new_mail();
-
- setup_msg_contents(
- cwc,
- "test@example.org",
- "will the 'No, Send Now' button work?",
- "Hello, I got your attachment!"
- );
-
- wait_for_reminder_state(cwc, true);
-
- // Click the send button again, this time choose "No, Send Now".
- plan_for_modal_dialog("commonDialogWindow", click_no_send_now);
- cwc.click(cwc.eid("button-send"));
- wait_for_modal_dialog("commonDialogWindow");
-
- // After clicking "Send Now" sending is proceeding, just handle the error.
- click_send_and_handle_send_error(cwc, true);
-
- // We're now back in the compose window, let's close it then.
- close_compose_window(cwc);
-}
-
-/**
- * Click the manual reminder in the menu.
- *
- * @param aCwc A compose window controller.
- * @param aExpectedState A boolean specifying what is the expected state
- * of the reminder menuitem after the click.
- */
-function click_manual_reminder(aCwc, aExpectedState) {
- wait_for_window_focused(aCwc.window);
- let button = aCwc.window.document.getElementById("button-attach");
-
- aCwc.click(
- new elementslib.Elem(
- button.querySelector(".toolbarbutton-menubutton-dropmarker")
- )
- );
- aCwc.click_menus_in_sequence(aCwc.e("button-attachPopup"), [
- { id: "button-attachPopup_remindLaterItem" },
- ]);
- wait_for_window_focused(aCwc.window);
- assert_manual_reminder_state(aCwc, aExpectedState);
-}
-
-/**
- * Bug 521128
- * Test proper behaviour of the manual reminder.
- */
-function test_manual_attachment_reminder() {
- // Open a sample message with no attachment keywords.
- let cwc = open_compose_new_mail();
- setup_msg_contents(
- cwc,
- "test@example.invalid",
- "Testing manual reminder!",
- "Some body..."
- );
-
- // Enable the manual reminder.
- click_manual_reminder(cwc, true);
- // There should be no attachment notification.
- assert_automatic_reminder_state(cwc, false);
-
- // Now close the message with saving it as draft.
- plan_for_modal_dialog("commonDialogWindow", click_save_message);
- cwc.window.goDoCommand("cmd_close");
- wait_for_modal_dialog("commonDialogWindow");
-
- // Open another blank compose window.
- cwc = open_compose_new_mail();
- // This one should have the reminder disabled.
- assert_manual_reminder_state(cwc, false);
- // There should be no attachment notification.
- assert_automatic_reminder_state(cwc, false);
-
- close_compose_window(cwc);
-
- // The draft message was saved into Local Folders/Drafts.
- be_in_folder(gDrafts);
-
- select_click_row(0);
- // Wait for the notification with the Edit button.
- wait_for_notification_to_show(mc, "mail-notification-top", "draftMsgContent");
- // Edit the draft again...
- plan_for_new_window("msgcompose");
- // ... by clicking Edit in the draft message notification bar.
- mc.click(
- mc.eid("mail-notification-top", { tagName: "button", label: "Edit" })
- );
- cwc = wait_for_compose_window();
-
- // Check the reminder enablement was preserved in the message.
- assert_manual_reminder_state(cwc, true);
- // There should be no attachment notification.
- assert_automatic_reminder_state(cwc, false);
-
- // Now try to send, make sure we get the alert.
- plan_for_modal_dialog("commonDialogWindow", click_oh_i_did);
- cwc.click(cwc.eid("button-send"));
- wait_for_modal_dialog("commonDialogWindow");
-
- // We were alerted once and the manual reminder is automatically turned off.
- assert_manual_reminder_state(cwc, false);
-
- // Enable the manual reminder and disable it again to see if it toggles right.
- click_manual_reminder(cwc, true);
- cwc.sleep(2000);
- click_manual_reminder(cwc, false);
-
- // Now try to send again, there should be no more alert.
- click_send_and_handle_send_error(cwc);
-
- close_compose_window(cwc);
-
- // Delete the leftover draft message.
- press_delete();
-}
-test_manual_attachment_reminder.EXCLUDED_PLATFORMS = ["winnt", "linux"]; // See bug 1535292.
-
-/**
- * Bug 938759
- * Test hiding of the automatic notification if the manual reminder is set.
- */
-function test_manual_automatic_attachment_reminder_interaction() {
- // Open a blank message compose
- let cwc = open_compose_new_mail();
- // This one should have the reminder disabled.
- assert_manual_reminder_state(cwc, false);
- // There should be no attachment notification.
- assert_automatic_reminder_state(cwc, false);
-
- // Add some attachment keywords.
- setup_msg_contents(
- cwc,
- "test@example.invalid",
- "Testing manual reminder!",
- "Expect an attachment here..."
- );
-
- // The automatic attachment notification should pop up.
- wait_for_reminder_state(cwc, true);
-
- // Now enable the manual reminder.
- click_manual_reminder(cwc, true);
- // The attachment notification should disappear.
- wait_for_reminder_state(cwc, false);
-
- // Add some more text so the automatic notification
- // could potentially show up.
- setup_msg_contents(cwc, "", "", " and look for your attachment!");
- // Give the notification time to appear. It shouldn't.
- wait_for_reminder_state(cwc, false);
-
- // Now disable the manual reminder.
- click_manual_reminder(cwc, false);
- // Give the notification time to appear. It shouldn't.
- wait_for_reminder_state(cwc, false);
-
- // Add some more text without keywords.
- setup_msg_contents(cwc, "", "", " No keywords here.");
- // Give the notification time to appear. It shouldn't.
- wait_for_reminder_state(cwc, false);
-
- // Add some more text with a new keyword.
- setup_msg_contents(cwc, "", "", " Do you find it attached?");
- // Give the notification time to appear. It should now.
- wait_for_reminder_state(cwc, true);
- assert_equals(get_reminder_keywords(cwc), "attachment, attached");
-
- close_compose_window(cwc);
-}
-
-/**
- * Assert if there is any notification in the compose window.
- *
- * @param aCwc Compose Window Controller
- * @param aValue True if notification should exist.
- * False otherwise.
- */
-function assert_any_notification(aCwc, aValue) {
- let notification = aCwc.e(kBoxId).currentNotification;
- if ((notification == null) == aValue) {
- throw new Error("Notification in wrong state");
- }
-}
-
-/**
- * Bug 989653
- * Send filelink attachment should not trigger the attachment reminder.
- */
-function test_attachment_vs_filelink_reminder() {
- // Open a blank message compose
- let cwc = open_compose_new_mail();
- setup_msg_contents(
- cwc,
- "test@example.invalid",
- "Testing Filelink notification",
- "There is no body. I hope you don't mind!"
- );
-
- // There should be no notification yet.
- assert_any_notification(cwc, false);
-
- // Bring up the FileLink notification.
- let kOfferThreshold = "mail.compose.big_attachments.threshold_kb";
- let maxSize = Services.prefs.getIntPref(kOfferThreshold, 0) * 1024;
- let file = Services.dirsvc.get("ProfD", Ci.nsIFile);
- file.append("panacea.dat");
- add_attachments(cwc, Services.io.newFileURI(file).spec, maxSize);
-
- // The filelink attachment proposal should be up but not the attachment
- // reminder and it should also not interfere with the sending of the message.
- wait_for_notification_to_show(cwc, kBoxId, "bigAttachment");
- assert_automatic_reminder_state(cwc, false);
-
- click_send_and_handle_send_error(cwc);
- close_window(cwc);
-}
-
-/**
- * Bug 944643
- * Test the attachment reminder coming up when keyword is in subject line.
- */
-function test_attachment_reminder_in_subject() {
- // Open a blank message compose
- let cwc = open_compose_new_mail();
- // This one should have the reminder disabled.
- assert_manual_reminder_state(cwc, false);
- // There should be no attachment notification.
- assert_automatic_reminder_state(cwc, false);
-
- // Add some attachment keyword in subject.
- setup_msg_contents(
- cwc,
- "test@example.invalid",
- "Testing attachment reminder!",
- "There is no keyword in this body..."
- );
-
- // The automatic attachment notification should pop up.
- wait_for_reminder_state(cwc, true);
- assert_equals(get_reminder_keywords(cwc), "attachment");
-
- // Now clear the subject
- delete_all_existing(cwc, cwc.eid("msgSubject"));
-
- // Give the notification time to disappear.
- wait_for_reminder_state(cwc, false);
-
- close_compose_window(cwc);
-}
-
-/**
- * Bug 944643
- * Test the attachment reminder coming up when keyword is in subject line
- * and also body.
- */
-function test_attachment_reminder_in_subject_and_body() {
- // Open a blank message compose
- let cwc = open_compose_new_mail();
- // This one should have the reminder disabled.
- assert_manual_reminder_state(cwc, false);
- // There should be no attachment notification.
- assert_automatic_reminder_state(cwc, false);
-
- // Add some attachment keyword in subject.
- setup_msg_contents(
- cwc,
- "test@example.invalid",
- "Testing attachment reminder!",
- "There should be an attached file in this body..."
- );
-
- // The automatic attachment notification should pop up.
- wait_for_reminder_state(cwc, true);
- assert_equals(get_reminder_keywords(cwc), "attachment, attached");
-
- // Now clear only the subject
- delete_all_existing(cwc, cwc.eid("msgSubject"));
-
- // Give the notification some time. It should not disappear,
- // just reduce the keywords list.
- wait_for_reminder_state(cwc, true, true);
- assert_equals(get_reminder_keywords(cwc), "attached");
-
- close_compose_window(cwc);
-}
-
-/**
- * Bug 1099866
- * Test proper behaviour of attachment reminder when keyword reminding
- * is turned off.
- */
-function test_disabled_attachment_reminder() {
- Services.prefs.setBoolPref(kReminderPref, false);
-
- // Open a sample message with no attachment keywords.
- let cwc = open_compose_new_mail();
- setup_msg_contents(
- cwc,
- "test@example.invalid",
- "Testing disabled keyword reminder!",
- "Some body..."
- );
-
- // This one should have the manual reminder disabled.
- assert_manual_reminder_state(cwc, false);
- // There should be no attachment notification.
- assert_automatic_reminder_state(cwc, false);
-
- // Add some keyword so the automatic notification
- // could potentially show up.
- setup_msg_contents(cwc, "", "", " and look for your attachment!");
- // Give the notification time to appear. It shouldn't.
- wait_for_reminder_state(cwc, false);
-
- // Enable the manual reminder.
- click_manual_reminder(cwc, true);
- assert_automatic_reminder_state(cwc, false);
-
- // Disable the manual reminder and the notification should still be hidden
- // even when there are still keywords in the body.
- click_manual_reminder(cwc, false);
- assert_automatic_reminder_state(cwc, false);
-
- // There should be no attachment message upon send.
- click_send_and_handle_send_error(cwc);
-
- close_compose_window(cwc);
-
- Services.prefs.setBoolPref(kReminderPref, true);
-}
-
-/**
- * Bug 833909
- * Test reminder comes up when a draft with keywords is opened.
- */
-function test_reminder_in_draft() {
- // Open a sample message with no attachment keywords.
- let cwc = open_compose_new_mail();
- setup_msg_contents(
- cwc,
- "test@example.invalid",
- "Testing draft reminder!",
- "Some body..."
- );
-
- // This one should have the manual reminder disabled.
- assert_manual_reminder_state(cwc, false);
- // There should be no attachment notification.
- assert_automatic_reminder_state(cwc, false);
-
- // Add some keyword so the automatic notification
- // could potentially show up.
- setup_msg_contents(cwc, "", "", " and look for your attachment!");
-
- // Give the notification time to appear.
- wait_for_reminder_state(cwc, true);
-
- // Now close the message with saving it as draft.
- plan_for_modal_dialog("commonDialogWindow", click_save_message);
- cwc.window.goDoCommand("cmd_close");
- wait_for_modal_dialog("commonDialogWindow");
-
- // The draft message was saved into Local Folders/Drafts.
- be_in_folder(gDrafts);
-
- select_click_row(0);
- // Wait for the notification with the Edit button.
- wait_for_notification_to_show(mc, "mail-notification-top", "draftMsgContent");
- // Edit the draft again...
- plan_for_new_window("msgcompose");
- // ... by clicking Edit in the draft message notification bar.
- mc.click(
- mc.eid("mail-notification-top", { tagName: "button", label: "Edit" })
- );
- cwc = wait_for_compose_window();
-
- // Give the notification time to appear.
- wait_for_reminder_state(cwc, true);
-
- close_compose_window(cwc);
-
- // Delete the leftover draft message.
- press_delete();
-}
-
-/**
- * Bug 942436
- * Test that the reminder can be turned off for the current message.
- */
-function test_disabling_attachment_reminder() {
- // Open a sample message with attachment keywords.
- let cwc = open_compose_new_mail();
- setup_msg_contents(
- cwc,
- "test@example.invalid",
- "Testing turning off the reminder",
- "Some attachment keywords here..."
- );
-
- // This one should have the manual reminder disabled.
- assert_manual_reminder_state(cwc, false);
- // There should be an attachment reminder.
- wait_for_reminder_state(cwc, true);
-
- // Disable the reminder (not just dismiss) using the menuitem
- // in the notification bar menu-button.
- let disableButton = get_notification_button(cwc, kBoxId, kNotificationId, {
- popup: "reminderBarPopup",
- });
- cwc.click(new elementslib.Elem(disableButton.querySelector("dropmarker")));
- cwc.click_menus_in_sequence(cwc.e("reminderBarPopup"), [
- { id: "disableReminder" },
- ]);
-
- wait_for_reminder_state(cwc, false);
-
- // Add more keywords.
- setup_msg_contents(cwc, "", "", "... and another file attached.");
- // Give the notification time to appear. It shouldn't.
- wait_for_reminder_state(cwc, false);
-
- // Enable the manual reminder.
- // This overrides the previous explicit disabling of any reminder.
- click_manual_reminder(cwc, true);
- assert_automatic_reminder_state(cwc, false);
-
- // Disable the manual reminder and the notification should still be hidden
- // even when there are still keywords in the body.
- click_manual_reminder(cwc, false);
- assert_automatic_reminder_state(cwc, false);
-
- // Add more keywords to trigger automatic reminder.
- setup_msg_contents(cwc, "", "", "I enclosed another file.");
- // Give the notification time to appear. It should now.
- wait_for_reminder_state(cwc, true);
-
- // Disable the reminder again.
- disableButton = get_notification_button(cwc, kBoxId, kNotificationId, {
- popup: "reminderBarPopup",
- });
- cwc.click(new elementslib.Elem(disableButton.querySelector("dropmarker")));
- cwc.click_menus_in_sequence(cwc.e("reminderBarPopup"), [
- { id: "disableReminder" },
- ]);
- wait_for_reminder_state(cwc, false);
-
- // Now send the message.
- plan_for_window_close(cwc);
- cwc.window.goDoCommand("cmd_sendLater");
- wait_for_window_close();
-
- // There should be no alert so it is saved in Outbox.
- be_in_folder(gOutbox);
-
- select_click_row(0);
- // Delete the leftover outgoing message.
- press_delete();
-
- // Get back to the mail account for other tests.
- let mail = MailServices.accounts.defaultAccount.incomingServer.rootFolder;
- be_in_folder(mail);
-}
-
-/**
- * Click the send button and handle the send error dialog popping up.
- * It will return us back to the compose window.
- *
- * @param aController
- * @param aAlreadySending Set this to true if sending was already triggered
- * by other means.
- */
-function click_send_and_handle_send_error(aController, aAlreadySending) {
- plan_for_modal_dialog("commonDialogWindow", click_ok_on_send_error);
- if (!aAlreadySending) {
- aController.click(aController.eid("button-send"));
- }
- wait_for_modal_dialog("commonDialogWindow");
-}
-
-/**
- * Click the "Oh, I Did!" button in the attachment reminder dialog.
- */
-function click_oh_i_did(controller) {
- controller.window.document
- .querySelector("dialog")
- .getButton("extra1")
- .doCommand();
-}
-
-/**
- * Click the "No, Send Now" button in the attachment reminder dialog.
- */
-function click_no_send_now(controller) {
- controller.window.document
- .querySelector("dialog")
- .getButton("accept")
- .doCommand();
-}
-
-/**
- * Click Ok in the Send Message Error dialog.
- */
-function click_ok_on_send_error(controller) {
- if (controller.window.document.title != "Send Message Error") {
- throw new Error(
- "Not a send error dialog; title=" + controller.window.document.title
- );
- }
- controller.window.document
- .querySelector("dialog")
- .getButton("accept")
- .doCommand();
-}
-
-/**
- * Click Save in the Save message dialog.
- */
-function click_save_message(controller) {
- if (controller.window.document.title != "Save Message") {
- throw new Error(
- "Not a Save message dialog; title=" + controller.window.document.title
- );
- }
- controller.window.document
- .querySelector("dialog")
- .getButton("accept")
- .doCommand();
-}
deleted file mode 100644
--- a/mail/test/mozmill/composition/test-attachment.js
+++ /dev/null
@@ -1,983 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests attachment handling functionality of the message compose window.
- */
-
-"use strict";
-
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-var os = ChromeUtils.import("chrome://mozmill/content/stdlib/os.jsm");
-
-var {
- add_attachments,
- close_compose_window,
- delete_attachment,
- open_compose_new_mail,
- open_compose_with_forward,
- open_compose_with_forward_as_attachments,
-} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
-var {
- add_message_to_folder,
- assert_equals,
- be_in_folder,
- create_folder,
- create_message,
- select_click_row,
-
- wait_for_popup_to_open,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { plan_for_modal_dialog, wait_for_modal_dialog } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { AppConstants } = ChromeUtils.import(
- "resource://gre/modules/AppConstants.jsm"
-);
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var messenger;
-var folder;
-var epsilon;
-var isWindows;
-var filePrefix;
-
-var rawAttachment =
- "Can't make the frug contest, Helen; stomach's upset. I'll fix you, " +
- "Ubik! Ubik drops you back in the thick of things fast. Taken as " +
- "directed, Ubik speeds relief to head and stomach. Remember: Ubik is " +
- "only seconds away. Avoid prolonged use.";
-
-var b64Attachment =
- "iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAABHNCSVQICAgIfAhkiAAAAAlwS" +
- "FlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAA" +
- "A5SURBVCiRY/z//z8DKYCJJNXkaGBgYGD4D8NQ5zUgiTVAxeBqSLaBkVRPM0KtIhrQ3km0jwe" +
- "SNQAAlmAY+71EgFoAAAAASUVORK5CYII=";
-var b64Size = 188;
-
-function setupModule(module) {
- folder = create_folder("ComposeAttachmentA");
-
- messenger = Cc["@mozilla.org/messenger;1"].createInstance(Ci.nsIMessenger);
-
- isWindows = "@mozilla.org/windows-registry-key;1" in Cc;
-
- /* Today's gory details (thanks to Jonathan Protzenko): libmime somehow
- * counts the trailing newline for an attachment MIME part. Most of the time,
- * assuming attachment has N bytes (no matter what's inside, newlines or
- * not), libmime will return N + 1 bytes. On Linux and Mac, this always
- * holds. However, on Windows, if the attachment is not encoded (that is, is
- * inline text), libmime will return N + 2 bytes. Since we're dealing with
- * forwarded message data here, the bonus byte(s) appear twice.
- */
- epsilon = isWindows ? 4 : 2;
- filePrefix = isWindows ? "file:///C:/" : "file:///";
-
- // create some messages that have various types of attachments
- let messages = [
- // no attachment
- {},
- // raw attachment
- {
- attachments: [{ body: rawAttachment, filename: "ubik.txt", format: "" }],
- },
- // b64-encoded image attachment
- {
- attachments: [
- {
- body: b64Attachment,
- contentType: "image/png",
- filename: "lines.png",
- encoding: "base64",
- format: "",
- },
- ],
- },
- ];
-
- for (let i = 0; i < messages.length; i++) {
- add_message_to_folder(folder, create_message(messages[i]));
- }
-}
-
-/**
- * Make sure that the attachment's size is what we expect
- * @param controller the controller for the compose window
- * @param index the attachment to examine, as an index into the listbox
- * @param expectedSize the expected size of the attachment, in bytes
- */
-function check_attachment_size(controller, index, expectedSize) {
- let bucket = controller.e("attachmentBucket");
- let node = bucket.querySelectorAll("richlistitem.attachmentItem")[index];
-
- // First, let's check that the attachment size is correct
- let size = node.attachment.size;
- if (Math.abs(size - expectedSize) > epsilon) {
- throw new Error(
- "Reported attachment size (" +
- size +
- ") not within epsilon " +
- "of actual attachment size (" +
- expectedSize +
- ")"
- );
- }
-
- // Next, make sure that the formatted size in the label is correct
- let formattedSize = node.getAttribute("size");
- let expectedFormattedSize = messenger.formatFileSize(size);
- if (formattedSize != expectedFormattedSize) {
- throw new Error(
- "Formatted attachment size (" +
- formattedSize +
- ") does not " +
- "match expected value (" +
- expectedFormattedSize +
- ")"
- );
- }
-}
-
-/**
- * Make sure that the attachment's size is not displayed
- * @param controller the controller for the compose window
- * @param index the attachment to examine, as an index into the listbox
- */
-function check_no_attachment_size(controller, index) {
- let bucket = controller.e("attachmentBucket");
- let node = bucket.querySelectorAll("richlistitem.attachmentItem")[index];
-
- if (node.attachment.size != -1) {
- throw new Error("attachment.size attribute should be -1!");
- }
-
- // If there's no size, the size attribute is the zero-width space.
- if (node.getAttribute("size") != "\u200b") {
- throw new Error("Attachment size should not be displayed!");
- }
-}
-
-/**
- * Make sure that the total size of all attachments is what we expect.
- * @param controller the controller for the compose window
- * @param count the expected number of attachments
- */
-function check_total_attachment_size(controller, count) {
- let bucket = controller.e("attachmentBucket");
- let nodes = bucket.querySelectorAll("richlistitem.attachmentItem");
- let sizeNode = controller.e("attachmentBucketSize");
-
- if (nodes.length != count) {
- throw new Error(
- "Saw " + nodes.length + " attachments, but expected " + count
- );
- }
-
- let size = 0;
- for (let i = 0; i < nodes.length; i++) {
- let currSize = nodes[i].attachment.size;
- if (currSize != -1) {
- size += currSize;
- }
- }
-
- // Next, make sure that the formatted size in the label is correct
- let formattedSize = sizeNode.getAttribute("value");
- let expectedFormattedSize = messenger.formatFileSize(size);
- if (formattedSize != expectedFormattedSize) {
- throw new Error(
- "Formatted attachment size (" +
- formattedSize +
- ") does not " +
- "match expected value (" +
- expectedFormattedSize +
- ")"
- );
- }
-}
-
-function test_file_attachment() {
- let cwc = open_compose_new_mail();
-
- let url = filePrefix + "some/file/here.txt";
- let size = 1234;
-
- add_attachments(cwc, url, size);
- check_attachment_size(cwc, 0, size);
- check_total_attachment_size(cwc, 1);
-
- close_compose_window(cwc);
-}
-
-function test_webpage_attachment() {
- let cwc = open_compose_new_mail();
-
- add_attachments(cwc, "http://www.mozilla.org/");
- check_no_attachment_size(cwc, 0);
- check_total_attachment_size(cwc, 1);
-
- close_compose_window(cwc);
-}
-
-function test_multiple_attachments() {
- let cwc = open_compose_new_mail();
-
- let files = [
- { name: "foo.txt", size: 1234 },
- { name: "bar.txt", size: 5678 },
- { name: "baz.txt", size: 9012 },
- ];
- for (let i = 0; i < files.length; i++) {
- add_attachments(cwc, filePrefix + files[i].name, files[i].size);
- check_attachment_size(cwc, i, files[i].size);
- }
-
- check_total_attachment_size(cwc, files.length);
- close_compose_window(cwc);
-}
-
-function test_delete_attachments() {
- let cwc = open_compose_new_mail();
-
- let files = [
- { name: "foo.txt", size: 1234 },
- { name: "bar.txt", size: 5678 },
- { name: "baz.txt", size: 9012 },
- ];
- for (let i = 0; i < files.length; i++) {
- add_attachments(cwc, filePrefix + files[i].name, files[i].size);
- check_attachment_size(cwc, i, files[i].size);
- }
-
- delete_attachment(cwc, 0);
- check_total_attachment_size(cwc, files.length - 1);
-
- close_compose_window(cwc);
-}
-
-function subtest_rename_attachment(cwc) {
- cwc.e("loginTextbox").value = "renamed.txt";
- cwc.window.document
- .querySelector("dialog")
- .getButton("accept")
- .doCommand();
-}
-
-function test_rename_attachment() {
- let cwc = open_compose_new_mail();
-
- let url = filePrefix + "some/file/here.txt";
- let size = 1234;
-
- add_attachments(cwc, url, size);
-
- // Now, rename the attachment.
- let bucket = cwc.e("attachmentBucket");
- let node = bucket.querySelector("richlistitem.attachmentItem");
- cwc.click(new elib.Elem(node));
- plan_for_modal_dialog("commonDialogWindow", subtest_rename_attachment);
- cwc.window.RenameSelectedAttachment();
- wait_for_modal_dialog("commonDialogWindow");
-
- assert_equals(node.getAttribute("name"), "renamed.txt");
-
- check_attachment_size(cwc, 0, size);
- check_total_attachment_size(cwc, 1);
-
- close_compose_window(cwc);
-}
-
-function subtest_open_attachment(cwc) {
- cwc.window.document
- .querySelector("dialog")
- .getButton("cancel")
- .doCommand();
-}
-
-function test_open_attachment() {
- let cwc = open_compose_new_mail();
-
- // set up our external file for attaching
- let thisFilePath = os.getFileForPath(__file__);
- let file = os.getFileForPath(os.abspath("./attachment.txt", thisFilePath));
- let fileHandler = Services.io
- .getProtocolHandler("file")
- .QueryInterface(Ci.nsIFileProtocolHandler);
- let url = fileHandler.getURLSpecFromFile(file);
- let size = file.fileSize;
-
- add_attachments(cwc, url, size);
-
- // Now, open the attachment.
- let bucket = cwc.e("attachmentBucket");
- let node = bucket.querySelector("richlistitem.attachmentItem");
- plan_for_modal_dialog("unknownContentTypeWindow", subtest_open_attachment);
- cwc.doubleClick(new elib.Elem(node));
- wait_for_modal_dialog("unknownContentTypeWindow");
-
- close_compose_window(cwc);
-}
-
-function test_forward_raw_attachment() {
- be_in_folder(folder);
- select_click_row(1);
-
- let cwc = open_compose_with_forward();
- check_attachment_size(cwc, 0, rawAttachment.length);
- check_total_attachment_size(cwc, 1);
-
- close_compose_window(cwc);
-}
-
-function test_forward_b64_attachment() {
- be_in_folder(folder);
- select_click_row(2);
-
- let cwc = open_compose_with_forward();
- check_attachment_size(cwc, 0, b64Size);
- check_total_attachment_size(cwc, 1);
-
- close_compose_window(cwc);
-}
-
-function test_forward_message_as_attachment() {
- be_in_folder(folder);
- let curMessage = select_click_row(0);
-
- let cwc = open_compose_with_forward_as_attachments();
- check_attachment_size(cwc, 0, curMessage.messageSize);
- check_total_attachment_size(cwc, 1);
-
- close_compose_window(cwc);
-}
-
-function test_forward_message_with_attachments_as_attachment() {
- be_in_folder(folder);
- let curMessage = select_click_row(1);
-
- let cwc = open_compose_with_forward_as_attachments();
- check_attachment_size(cwc, 0, curMessage.messageSize);
- check_total_attachment_size(cwc, 1);
-
- close_compose_window(cwc);
-}
-
-/**
- * Check that the compose window has the attachments we expect.
- *
- * @param aController The controller for the compose window
- * @param aNames An array of attachment names that are expected
- */
-function check_attachment_names(aController, aNames) {
- let bucket = aController.e("attachmentBucket");
- assert_equals(aNames.length, bucket.itemCount);
- for (let i = 0; i < aNames.length; i++) {
- assert_equals(bucket.getItemAtIndex(i).getAttribute("name"), aNames[i]);
- }
-}
-
-/**
- * Execute a test of opening and closing reorderAttachmentsPanel via keyboard.
- *
- * @param aCwc The controller for the compose window
- * @param aActions An array of objects specifying an action of opening the
- * panel via keyboard.
- * { focusEl: the element to be focused for keypresses
- * key: keycode of key to press
- * key_modifiers: { accelKey: bool, ctrlKey: bool
- * shiftKey: bool, altKey: bool, etc. },
- * }
- */
-function subtest_reordering_panel_keyboard(aCwc, aActions) {
- let panel = aCwc.e("reorderAttachmentsPanel");
-
- for (let action of aActions) {
- aCwc.keypress(
- new elib.Elem(action.focusEl),
- action.key,
- action.key_modifiers
- );
- wait_for_popup_to_open(panel);
- aCwc.sleep(0);
-
- // Press ESC which should close the panel.
- aCwc.keypress(null, "VK_ESCAPE", {});
- aCwc.sleep(0);
- aCwc.waitFor(
- () => panel.state == "closed",
- "Reordering panel didn't close when Escape was pressed."
- );
- }
-}
-
-/**
- * Execute a test of attachment reordering actions and check the resulting order.
- *
- * @param aCwc The controller for the compose window
- * @param aInitialAttachmentNames An array of attachment names specifying the
- * initial set of attachments to be created
- * @param aReorder_actions An array of objects specifying a reordering action:
- * { select: array of attachment item indexes to select,
- * button: ID of button to click in the reordering menu,
- * key: keycode of key to press instead of a click,
- * key_modifiers: { accelKey: bool, ctrlKey: bool
- * shiftKey: bool, altKey: bool, etc.},
- * result: an array of attachment names in the new
- * order that should result
- * }
- * @param openPanel {boolean} Whether to open reorderAttachmentsPanel for the test
- */
-function subtest_reordering(
- aCwc,
- aInitialAttachmentNames,
- aReorder_actions,
- aOpenPanel = true
-) {
- let bucket = aCwc.e("attachmentBucket");
- let panel;
-
- // Create a set of attachments for the test.
- const size = 1234;
- for (let name of aInitialAttachmentNames) {
- add_attachments(aCwc, filePrefix + name, size);
- }
- aCwc.sleep(0);
- assert_equals(aCwc.window.attachmentsCount(), aInitialAttachmentNames.length);
- check_attachment_names(aCwc, aInitialAttachmentNames);
-
- if (aOpenPanel) {
- // Bring up the reordering panel.
- aCwc.window.showReorderAttachmentsPanel();
- aCwc.sleep(0);
- panel = aCwc.e("reorderAttachmentsPanel");
- wait_for_popup_to_open(panel);
- }
-
- for (let action of aReorder_actions) {
- // Ensure selection.
- bucket.clearSelection();
- for (let itemIndex of action.select) {
- bucket.addItemToSelection(bucket.getItemAtIndex(itemIndex));
- }
- // Take action.
- if ("button" in action) {
- aCwc.click(aCwc.eid(action.button));
- } else if ("key" in action) {
- aCwc.keypress(null, action.key, action.key_modifiers);
- }
- aCwc.sleep(0);
- // Check result.
- check_attachment_names(aCwc, action.result);
- }
-
- if (aOpenPanel) {
- // Close the panel.
- panel.hidePopup();
- aCwc.waitFor(
- () => panel.state == "closed",
- "Reordering panel didn't close"
- );
- }
-
- // Clean up for a new set of attachments.
- aCwc.window.RemoveAllAttachments();
-}
-
-/**
- * Bug 663695, Bug 1417856, Bug 1426344, Bug 1425891, Bug 1427037.
- * Check basic and advanced attachment reordering operations.
- * This is the main function of this test.
- */
-function test_attachment_reordering() {
- let cwc = open_compose_new_mail();
- let editorEl = cwc.window.GetCurrentEditorElement();
- let bucket = cwc.e("attachmentBucket");
- let panel = cwc.e("reorderAttachmentsPanel");
- // const openReorderPanelModifiers =
- // (AppConstants.platform == "macosx") ? { controlKey: true }
- // : { altKey: true };
-
- // First, some checks if the 'Reorder Attachments' panel
- // opens and closes correctly.
-
- // Create two attachments as otherwise the reordering panel won't open.
- const size = 1234;
- const initialAttachmentNames_0 = ["A1", "A2"];
- for (let name of initialAttachmentNames_0) {
- add_attachments(cwc, filePrefix + name, size);
- cwc.sleep(0);
- }
- assert_equals(cwc.window.attachmentsCount(), initialAttachmentNames_0.length);
- check_attachment_names(cwc, initialAttachmentNames_0);
-
- // Show 'Reorder Attachments' panel via mouse clicks.
- cwc.rightClick(new elib.Elem(bucket.getItemAtIndex(1)));
- cwc.click_menus_in_sequence(cwc.e("msgComposeAttachmentItemContext"), [
- { id: "composeAttachmentContext_reorderItem" },
- ]);
- wait_for_popup_to_open(panel);
-
- // Click on the editor which should close the panel.
- cwc.click(new elib.Elem(editorEl));
- cwc.waitFor(
- () => panel.state == "closed",
- "Reordering panel didn't close when editor was clicked."
- );
-
- // Show 'Reorder Attachments' panel via keyboard.
- // key_reorderAttachments, Bug 1427037
- // const openPanelActions = [
- // { focusEl: editorEl,
- // key: "x",
- // key_modifiers: openReorderPanelModifiers },
- // { focusEl: bucket,
- // key: "x",
- // key_modifiers: openReorderPanelModifiers },
- // ];
-
- // XXX this doesn't work on any platform yet, ESC doesn't close the panel.
- // Execute test of opening 'Reorder Attachments' panel via keyboard.
- // subtest_reordering_panel_keyboard(cwc, openPanelActions);
-
- // Clean up for a new set of attachments.
- cwc.window.RemoveAllAttachments();
-
- // Define checks for various moving operations.
- // Check 1: basic, mouse-only.
- const initialAttachmentNames_1 = ["a", "C", "B", "b", "bb", "x"];
- const reorderActions_1 = [
- {
- select: [1, 2, 3],
- button: "btn_sortAttachmentsToggle",
- result: ["a", "b", "B", "C", "bb", "x"],
- },
- {
- select: [4],
- button: "btn_moveAttachmentUp",
- result: ["a", "b", "B", "bb", "C", "x"],
- },
- {
- select: [5],
- button: "btn_moveAttachmentTop",
- result: ["x", "a", "b", "B", "bb", "C"],
- },
- {
- select: [0],
- button: "btn_moveAttachmentDown",
- result: ["a", "x", "b", "B", "bb", "C"],
- },
- {
- select: [1],
- button: "btn_moveAttachmentBottom",
- result: ["a", "b", "B", "bb", "C", "x"],
- },
- {
- select: [1, 3],
- button: "btn_moveAttachmentBundleUp",
- result: ["a", "b", "bb", "B", "C", "x"],
- },
- // Bug 1417856
- {
- select: [2],
- button: "btn_sortAttachmentsToggle",
- result: ["a", "b", "B", "bb", "C", "x"],
- },
- ];
-
- // Check 2: basic and advanced, mouse-only.
- const initialAttachmentNames_2 = [
- "a",
- "x",
- "C",
- "y1",
- "y2",
- "B",
- "b",
- "z",
- "bb",
- ];
- const reorderActions_2 = [
- // For starters: moving a single attachment around in the list.
- {
- select: [1],
- button: "btn_moveAttachmentUp",
- result: ["x", "a", "C", "y1", "y2", "B", "b", "z", "bb"],
- },
- {
- select: [0],
- button: "btn_moveAttachmentBottom",
- result: ["a", "C", "y1", "y2", "B", "b", "z", "bb", "x"],
- },
- {
- select: [8],
- button: "btn_moveAttachmentTop",
- result: ["x", "a", "C", "y1", "y2", "B", "b", "z", "bb"],
- },
- {
- select: [0],
- button: "btn_moveAttachmentDown",
- result: ["a", "x", "C", "y1", "y2", "B", "b", "z", "bb"],
- },
-
- // Moving multiple, disjunct selection with inner block up/down as-is.
- // This feature can be useful for multiple disjunct selection patterns
- // in an alternating list of attachments like
- // {photo1.jpg, description1.txt, photo2.jpg, description2.txt},
- // where the order of alternation should be inverted to become
- // {description1.txt, photo1.jpg, description2.txt, photo2.txt}.
- {
- select: [1, 3, 4, 7],
- button: "btn_moveAttachmentDown",
- result: ["a", "C", "x", "B", "y1", "y2", "b", "bb", "z"],
- },
- {
- select: [2, 4, 5, 8],
- button: "btn_moveAttachmentUp",
- result: ["a", "x", "C", "y1", "y2", "B", "b", "z", "bb"],
- },
- {
- select: [1, 3, 4, 7],
- button: "btn_moveAttachmentUp",
- result: ["x", "a", "y1", "y2", "C", "B", "z", "b", "bb"],
- },
-
- // Folding multiple, disjunct selection with inner block towards top/bottom.
- {
- select: [0, 2, 3, 6],
- button: "btn_moveAttachmentUp",
- result: ["x", "y1", "y2", "a", "C", "z", "B", "b", "bb"],
- },
- {
- select: [0, 1, 2, 5],
- button: "btn_moveAttachmentUp",
- result: ["x", "y1", "y2", "a", "z", "C", "B", "b", "bb"],
- },
- {
- select: [0, 1, 2, 4],
- button: "btn_moveAttachmentUp",
- result: ["x", "y1", "y2", "z", "a", "C", "B", "b", "bb"],
- },
- {
- select: [3, 5, 6, 8],
- button: "btn_moveAttachmentDown",
- result: ["x", "y1", "y2", "a", "z", "b", "C", "B", "bb"],
- },
- {
- select: [4, 6, 7, 8],
- button: "btn_moveAttachmentDown",
- result: ["x", "y1", "y2", "a", "b", "z", "C", "B", "bb"],
- },
-
- // Prepare scenario for and test 'Group together' (upwards).
- {
- select: [1, 2],
- button: "btn_moveAttachmentDown",
- result: ["x", "a", "y1", "y2", "b", "z", "C", "B", "bb"],
- },
- {
- select: [0, 2, 3, 5],
- button: "btn_moveAttachmentDown",
- result: ["a", "x", "b", "y1", "y2", "C", "z", "B", "bb"],
- },
- {
- select: [1, 3, 4, 6],
- button: "btn_moveAttachmentBundleUp",
- result: ["a", "x", "y1", "y2", "z", "b", "C", "B", "bb"],
- },
- // 'Group together' (downwards) is not tested here because it is
- // only available via keyboard shortcuts, e.g. Alt+Cursor Right.
-
- // Sort selected attachments only.
- // Unsorted multiple selection must be collapsed upwards first if disjunct,
- // then sorted ascending.
- {
- select: [0, 5, 6, 8],
- button: "btn_sortAttachmentsToggle",
- result: ["a", "b", "bb", "C", "x", "y1", "y2", "z", "B"],
- },
- // Sorted multiple block selection must be sorted the other way round.
- {
- select: [0, 1, 2, 3],
- button: "btn_sortAttachmentsToggle",
- result: ["C", "bb", "b", "a", "x", "y1", "y2", "z", "B"],
- },
- // Sorted, multiple, disjunct selection must just be collapsed upwards.
- {
- select: [3, 8],
- button: "btn_sortAttachmentsToggle",
- result: ["C", "bb", "b", "a", "B", "x", "y1", "y2", "z"],
- },
- {
- select: [0, 2, 3],
- button: "btn_sortAttachmentsToggle",
- result: ["C", "b", "a", "bb", "B", "x", "y1", "y2", "z"],
- },
-
- // Bug 1417856: Sort all attachments when 1 or no attachment selected.
- {
- select: [1],
- button: "btn_sortAttachmentsToggle",
- result: ["a", "b", "B", "bb", "C", "x", "y1", "y2", "z"],
- },
- {
- select: [],
- button: "btn_sortAttachmentsToggle",
- result: ["z", "y2", "y1", "x", "C", "bb", "B", "b", "a"],
- },
-
- // Collapsing multiple, disjunct selection with inner block to top/bottom.
- {
- select: [3, 5, 6, 8],
- button: "btn_moveAttachmentTop",
- result: ["x", "bb", "B", "a", "z", "y2", "y1", "C", "b"],
- },
- {
- select: [0, 2, 3, 7],
- button: "btn_moveAttachmentBottom",
- result: ["bb", "z", "y2", "y1", "b", "x", "B", "a", "C"],
- },
- ];
-
- // Check 3: basic and advanced, keyboard-only.
- const initialAttachmentNames_3 = [
- "a",
- "x",
- "C",
- "y1",
- "y2",
- "B",
- "b",
- "z",
- "bb",
- ];
- const modAlt = { altKey: true };
- const modifiers2 =
- AppConstants.platform == "macosx"
- ? { accelKey: true, altKey: true }
- : { altKey: true };
- const reorderActions_3 = [
- // For starters: moving a single attachment around in the list.
- {
- select: [1],
- // key_moveAttachmentUp
- key: "VK_UP",
- key_modifiers: modAlt,
- result: ["x", "a", "C", "y1", "y2", "B", "b", "z", "bb"],
- },
- {
- select: [0],
- // key_moveAttachmentBottom
- key: AppConstants.platform == "macosx" ? "VK_DOWN" : "VK_END",
- key_modifiers: modifiers2,
- result: ["a", "C", "y1", "y2", "B", "b", "z", "bb", "x"],
- },
- {
- select: [8],
- // key_moveAttachmentTop
- key: AppConstants.platform == "macosx" ? "VK_UP" : "VK_HOME",
- key_modifiers: modifiers2,
- result: ["x", "a", "C", "y1", "y2", "B", "b", "z", "bb"],
- },
- {
- select: [0],
- // key_moveAttachmentBottom2 (secondary shortcut on MAC, same as Win primary)
- key: "VK_END",
- key_modifiers: modAlt,
- result: ["a", "C", "y1", "y2", "B", "b", "z", "bb", "x"],
- },
- {
- select: [8],
- // key_moveAttachmentTop2 (secondary shortcut on MAC, same as Win primary)
- key: "VK_HOME",
- key_modifiers: modAlt,
- result: ["x", "a", "C", "y1", "y2", "B", "b", "z", "bb"],
- },
- {
- select: [0],
- // key_moveAttachmentDown
- key: "VK_DOWN",
- key_modifiers: modAlt,
- result: ["a", "x", "C", "y1", "y2", "B", "b", "z", "bb"],
- },
-
- // Moving multiple, disjunct selection with inner block up/down as-is.
- // This feature can be useful for multiple disjunct selection patterns
- // in an alternating list of attachments like
- // {photo1.jpg, description1.txt, photo2.jpg, description2.txt},
- // where the order of alternation should be inverted to become
- // {description1.txt, photo1.jpg, description2.txt, photo2.txt}.
- {
- select: [1, 3, 4, 7],
- // key_moveAttachmentDown
- key: "VK_DOWN",
- key_modifiers: modAlt,
- result: ["a", "C", "x", "B", "y1", "y2", "b", "bb", "z"],
- },
- {
- select: [2, 4, 5, 8],
- // key_moveAttachmentUp
- key: "VK_UP",
- key_modifiers: modAlt,
- result: ["a", "x", "C", "y1", "y2", "B", "b", "z", "bb"],
- },
- {
- select: [1, 3, 4, 7],
- // key_moveAttachmentUp
- key: "VK_UP",
- key_modifiers: modAlt,
- result: ["x", "a", "y1", "y2", "C", "B", "z", "b", "bb"],
- },
-
- // Folding multiple, disjunct selection with inner block towards top/bottom.
- {
- select: [0, 2, 3, 6],
- // key_moveAttachmentUp
- key: "VK_UP",
- key_modifiers: modAlt,
- result: ["x", "y1", "y2", "a", "C", "z", "B", "b", "bb"],
- },
- {
- select: [0, 1, 2, 5],
- // key_moveAttachmentUp
- key: "VK_UP",
- key_modifiers: modAlt,
- result: ["x", "y1", "y2", "a", "z", "C", "B", "b", "bb"],
- },
- {
- select: [0, 1, 2, 4],
- // key_moveAttachmentUp
- key: "VK_UP",
- key_modifiers: modAlt,
- result: ["x", "y1", "y2", "z", "a", "C", "B", "b", "bb"],
- },
- {
- select: [3, 5, 6, 8],
- // key_moveAttachmentDown
- key: "VK_DOWN",
- key_modifiers: modAlt,
- result: ["x", "y1", "y2", "a", "z", "b", "C", "B", "bb"],
- },
- {
- select: [4, 6, 7, 8],
- // key_moveAttachmentDown
- key: "VK_DOWN",
- key_modifiers: modAlt,
- result: ["x", "y1", "y2", "a", "b", "z", "C", "B", "bb"],
- },
-
- // Prepare scenario for and test 'Group together' (upwards/downwards).
- {
- select: [1, 2],
- // key_moveAttachmentDown
- key: "VK_DOWN",
- key_modifiers: modAlt,
- result: ["x", "a", "y1", "y2", "b", "z", "C", "B", "bb"],
- },
- {
- select: [0, 2, 3, 5],
- // key_moveAttachmentDown
- key: "VK_DOWN",
- key_modifiers: modAlt,
- result: ["a", "x", "b", "y1", "y2", "C", "z", "B", "bb"],
- },
- {
- select: [1, 3, 4, 6],
- // key_moveAttachmentBundleUp
- key: "VK_LEFT",
- key_modifiers: modAlt,
- result: ["a", "x", "y1", "y2", "z", "b", "C", "B", "bb"],
- },
- {
- select: [5, 6],
- // key_moveAttachmentUp
- key: "VK_UP",
- key_modifiers: modAlt,
- result: ["a", "x", "y1", "y2", "b", "C", "z", "B", "bb"],
- },
- {
- select: [0, 4, 5, 7],
- // key_moveAttachmentBundleDown
- key: "VK_RIGHT",
- key_modifiers: modAlt,
- result: ["x", "y1", "y2", "z", "a", "b", "C", "B", "bb"],
- },
-
- // Collapsing multiple, disjunct selection with inner block to top/bottom.
- {
- select: [0, 4, 5, 7],
- // key_moveAttachmentTop
- key: AppConstants.platform == "macosx" ? "VK_UP" : "VK_HOME",
- key_modifiers: modifiers2,
- result: ["x", "a", "b", "B", "y1", "y2", "z", "C", "bb"],
- },
- {
- select: [0, 4, 5, 6],
- // key_moveAttachmentBottom
- key: AppConstants.platform == "macosx" ? "VK_DOWN" : "VK_END",
- key_modifiers: modifiers2,
- result: ["a", "b", "B", "C", "bb", "x", "y1", "y2", "z"],
- },
- {
- select: [0, 1, 3, 4],
- // key_moveAttachmentBottom2 (secondary shortcut on MAC, same as Win primary)
- key: "VK_END",
- key_modifiers: modAlt,
- result: ["B", "x", "y1", "y2", "z", "a", "b", "C", "bb"],
- },
- {
- select: [5, 6, 7, 8],
- // key_moveAttachmentTop2 (secondary shortcut on MAC, same as Win primary)
- key: "VK_HOME",
- key_modifiers: modAlt,
- result: ["a", "b", "C", "bb", "B", "x", "y1", "y2", "z"],
- },
- ];
-
- // Check 4: Alt+Y keyboard shortcut for sorting (Bug 1425891).
- const initialAttachmentNames_4 = [
- "a",
- "x",
- "C",
- "y1",
- "y2",
- "B",
- "b",
- "z",
- "bb",
- ];
-
- const reorderActions_4 = [
- {
- select: [1],
- // key_sortAttachmentsToggle
- key: "y",
- key_modifiers: modAlt,
- result: ["a", "b", "B", "bb", "C", "x", "y1", "y2", "z"],
- },
- ];
-
- // Execute the tests of reordering actions as defined above.
- subtest_reordering(cwc, initialAttachmentNames_1, reorderActions_1);
- subtest_reordering(cwc, initialAttachmentNames_2, reorderActions_2);
- // Check 3 (keyboard-only) with panel open.
- subtest_reordering(cwc, initialAttachmentNames_3, reorderActions_3);
- // Check 3 (keyboard-only) without panel.
- subtest_reordering(cwc, initialAttachmentNames_3, reorderActions_3, false);
- // Check 4 (Alt+Y keyboard shortcut for sorting) without panel.
- subtest_reordering(cwc, initialAttachmentNames_4, reorderActions_4, false);
- // Check 4 (Alt+Y keyboard shortcut for sorting) with panel open.
- subtest_reordering(cwc, initialAttachmentNames_4, reorderActions_4);
- // XXX When the root problem of bug 1425891 has been found and fixed, we should
- // test here if the panel stays open as it should, esp. on Windows.
-
- close_compose_window(cwc);
-}
-
-// XXX: Test attached emails dragged onto composer and files pulled from other
-// emails (this probably requires better drag-and-drop support from Mozmill)
deleted file mode 100644
--- a/mail/test/mozmill/composition/test-base64-display.js
+++ /dev/null
@@ -1,33 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests that messages with "broken" base64 are correctly displayed.
- */
-
-"use strict";
-
-var os = ChromeUtils.import("chrome://mozmill/content/stdlib/os.jsm");
-
-var { assert_true, open_message_from_file } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { close_window } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-function test_base64_display() {
- let file = os.getFileForPath(
- os.abspath("./base64-with-whitespace.eml", os.getFileForPath(__file__))
- );
- let msgc = open_message_from_file(file);
- let bodyText = msgc.e("messagepane").contentDocument.querySelector("body")
- .textContent;
- close_window(msgc);
-
- assert_true(
- bodyText.includes("abcdefghijklmnopqrstuvwxyz"),
- "Decoded base64 text not found in message."
- );
-}
deleted file mode 100644
--- a/mail/test/mozmill/composition/test-blocked-content.js
+++ /dev/null
@@ -1,153 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests that we do the right thing wrt. blocked resources during composition.
- */
-
-"use strict";
-
-var os = ChromeUtils.import("chrome://mozmill/content/stdlib/os.jsm");
-
-var {
- get_msg_source,
- open_compose_new_mail,
- setup_msg_contents,
-} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
-var {
- assert_false,
- assert_true,
- be_in_folder,
- get_special_folder,
- press_delete,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { wait_for_notification_to_show } = ChromeUtils.import(
- "resource://testing-common/mozmill/NotificationBoxHelpers.jsm"
-);
-var { plan_for_window_close, wait_for_window_close } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-var { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm");
-
-var gOutboxFolder;
-
-var kBoxId = "compose-notification-bottom";
-var kNotificationId = "blockedContent";
-
-function setupModule(module) {
- gOutboxFolder = get_special_folder(Ci.nsMsgFolderFlags.Queue);
-}
-
-function putHTMLOnClipboard(html) {
- let trans = Cc["@mozilla.org/widget/transferable;1"].createInstance(
- Ci.nsITransferable
- );
-
- // Register supported data flavors
- trans.init(null);
- trans.addDataFlavor("text/html");
-
- let wapper = Cc["@mozilla.org/supports-string;1"].createInstance(
- Ci.nsISupportsString
- );
- wapper.data = html;
- trans.setTransferData("text/html", wapper);
-
- Services.clipboard.setData(trans, null, Ci.nsIClipboard.kGlobalClipboard);
-}
-
-/**
- * Test that accessing file: URLs will block when appropriate, and load
- * the content when appropriate.
- */
-function test_paste_file_urls() {
- let cwc = open_compose_new_mail();
- setup_msg_contents(
- cwc,
- "someone@example.com",
- "testing html paste",
- "See these images- one broken one not\n"
- );
-
- const fname = "./tb-logo.png";
- let file = os.getFileForPath(os.abspath(fname, os.getFileForPath(__file__)));
- let fileHandler = Services.io
- .getProtocolHandler("file")
- .QueryInterface(Ci.nsIFileProtocolHandler);
-
- let dest = OS.Path.join(OS.Constants.Path.tmpDir, file.leafName);
- let tmpFile;
- let tmpFileURL;
- OS.File.remove(dest, { ignoreAbsent: true })
- .then(function() {
- return OS.File.copy(file.path, dest);
- })
- .then(function() {
- return OS.File.setDates(dest, null, null);
- })
- .then(function() {
- tmpFile = os.getFileForPath(dest);
- assert_true(tmpFile.exists(), "tmpFile's not there at " + dest);
-
- tmpFileURL = fileHandler.getURLSpecFromFile(tmpFile);
- putHTMLOnClipboard(
- "<img id='bad-img' src='file://foo/non-existant' alt='bad' /> and " +
- "<img id='tmp-img' src='" +
- tmpFileURL +
- "' alt='tmp' />"
- );
-
- cwc.e("content-frame").focus();
- // Ctrl+V = Paste
- cwc.keypress(null, "v", { shiftKey: false, accelKey: true });
- })
- .catch(function(err) {
- throw new Error("Setting up img file FAILED: " + err);
- });
-
- // Now wait for the paste, and for the file: based image to get converted
- // to data:.
- cwc.waitFor(function() {
- let img = cwc.e("content-frame").contentDocument.getElementById("tmp-img");
- return img && img.naturalHeight == 84 && img.src.startsWith("data:");
- }, "Timeout waiting for pasted tmp image to be loaded ok");
-
- // For the non-existent (non-accessible!) image we should get a notification.
- wait_for_notification_to_show(cwc, kBoxId, kNotificationId);
-
- plan_for_window_close(cwc);
- cwc.window.goDoCommand("cmd_sendLater");
- wait_for_window_close();
-
- be_in_folder(gOutboxFolder);
- let outMsg = select_click_row(0);
- let outMsgContent = get_msg_source(outMsg);
-
- assert_true(
- outMsgContent.includes("file://foo/non-existant"),
- "non-existant file not in content=" + outMsgContent
- );
-
- assert_false(
- outMsgContent.includes(tmpFileURL),
- "tmp file url still in content=" + outMsgContent
- );
-
- assert_true(
- outMsgContent.includes('id="tmp-img" src="cid:'),
- "tmp-img should be cid after send; content=" + outMsgContent
- );
-
- press_delete(); // Delete the msg from Outbox.
-}
-
-function teardownModule(module) {}
deleted file mode 100644
--- a/mail/test/mozmill/composition/test-charset-edit.js
+++ /dev/null
@@ -1,224 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests that we do the right thing wrt. message encoding when editing or
- * replying to messages.
- */
-
-"use strict";
-
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-var os = ChromeUtils.import("chrome://mozmill/content/stdlib/os.jsm");
-var utils = ChromeUtils.import("chrome://mozmill/content/modules/utils.jsm");
-
-var {
- close_compose_window,
- open_compose_with_reply,
- wait_for_compose_window,
-} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
-var {
- add_message_to_folder,
- assert_equals,
- assert_selected_and_displayed,
- be_in_folder,
- create_message,
- get_special_folder,
- mc,
- press_delete,
- select_click_row,
- SyntheticPartLeaf,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { wait_for_notification_to_show } = ChromeUtils.import(
- "resource://testing-common/mozmill/NotificationBoxHelpers.jsm"
-);
-var { plan_for_new_window } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-var { MimeParser } = ChromeUtils.import("resource:///modules/mimeParser.jsm");
-
-var gDrafts;
-
-function setupModule(module) {
- gDrafts = get_special_folder(Ci.nsMsgFolderFlags.Drafts, true);
-
- // Ensure reply charset isn't UTF-8, otherwise there's no need to upgrade,
- // which is what this test tests.
- let str = Cc["@mozilla.org/pref-localizedstring;1"].createInstance(
- Ci.nsIPrefLocalizedString
- );
- str.data = "windows-1252";
- Services.prefs.setComplexValue(
- "mailnews.send_default_charset",
- Ci.nsIPrefLocalizedString,
- str
- );
-}
-
-/**
- * Helper to get the full message content.
- *
- * @param aMsgHdr: nsIMsgDBHdr object whose text body will be read
- * @param aGetText: if true, return header objects. if false, return body data.
- * @return Map(partnum -> message headers)
- */
-function getMsgHeaders(aMsgHdr, aGetText = false) {
- let msgFolder = aMsgHdr.folder;
- let msgUri = msgFolder.getUriForMsg(aMsgHdr);
-
- let messenger = Cc["@mozilla.org/messenger;1"].createInstance(
- Ci.nsIMessenger
- );
- let handler = {
- _done: false,
- _data: new Map(),
- _text: new Map(),
- endMessage() {
- this._done = true;
- },
- deliverPartData(num, text) {
- this._text.set(num, this._text.get(num) + text);
- },
- startPart(num, headers) {
- this._data.set(num, headers);
- this._text.set(num, "");
- },
- };
- let streamListener = MimeParser.makeStreamListenerParser(handler, {
- strformat: "unicode",
- });
- messenger
- .messageServiceFromURI(msgUri)
- .streamMessage(msgUri, streamListener, null, null, false, "", false);
- utils.waitFor(() => handler._done);
- return aGetText ? handler._text : handler._data;
-}
-
-/**
- * Test that if we reply to a message in an invalid charset, we don't try to compose
- * in that charset. Instead, we should be using the default charset (set to
- * not be UTF-8 in this test).
- */
-function test_wrong_reply_charset() {
- let folder = gDrafts;
- let msg0 = create_message({
- bodyPart: new SyntheticPartLeaf("Some text", {
- charset: "invalid-charset",
- }),
- });
- add_message_to_folder(folder, msg0);
- be_in_folder(folder);
- let msg = select_click_row(0);
- assert_selected_and_displayed(mc, msg);
- assert_equals(getMsgHeaders(msg).get("").charset, "invalid-charset");
-
- let rwc = open_compose_with_reply();
- // Ctrl+S = save as draft.
- rwc.keypress(null, "s", { shiftKey: false, accelKey: true });
- close_compose_window(rwc);
-
- let draftMsg = select_click_row(1);
- assert_equals(getMsgHeaders(draftMsg).get("").charset, "windows-1252");
- press_delete(mc); // Delete message
-
- // Edit the original message. Charset should be windows-1252 now.
- msg = select_click_row(0);
-
- // Wait for the notification with the Edit button.
- wait_for_notification_to_show(mc, "mail-notification-top", "draftMsgContent");
-
- plan_for_new_window("msgcompose");
- mc.click(
- mc.eid("mail-notification-top", { tagName: "button", label: "Edit" })
- );
- rwc = wait_for_compose_window();
- rwc.keypress(null, "s", { shiftKey: false, accelKey: true });
- close_compose_window(rwc);
- msg = select_click_row(0);
- assert_equals(getMsgHeaders(msg).get("").charset, "windows-1252");
- press_delete(mc); // Delete message
-}
-
-/**
- * Test that replying to bad charsets don't screw up the existing text.
- */
-function test_no_mojibake() {
- let folder = gDrafts;
- let nonASCII = "ケツァルコアトル";
- let UTF7 = "+MLEwxDChMOswszCiMMgw6w-";
- let msg0 = create_message({
- bodyPart: new SyntheticPartLeaf(UTF7, { charset: "utf-7" }),
- });
- add_message_to_folder(folder, msg0);
- be_in_folder(folder);
- let msg = select_click_row(0);
- assert_selected_and_displayed(mc, msg);
- assert_equals(getMsgHeaders(msg).get("").charset, "utf-7");
- assert_equals(
- getMsgHeaders(msg, true)
- .get("")
- .trim(),
- nonASCII
- );
-
- let rwc = open_compose_with_reply();
- // Ctrl+S = save as draft.
- rwc.keypress(null, "s", { shiftKey: false, accelKey: true });
- close_compose_window(rwc);
-
- let draftMsg = select_click_row(1);
- assert_equals(
- getMsgHeaders(draftMsg)
- .get("")
- .charset.toUpperCase(),
- "UTF-8"
- );
- let text = getMsgHeaders(draftMsg, true).get("");
- // Delete message first before throwing so subsequent tests are not affected.
- press_delete(mc);
- if (!text.includes(nonASCII)) {
- throw new Error("Expected to find " + nonASCII + " in " + text);
- }
-
- // Edit the original message. Charset should be UTF-8 now.
- msg = select_click_row(0);
-
- // Wait for the notification with the Edit button.
- wait_for_notification_to_show(mc, "mail-notification-top", "draftMsgContent");
-
- plan_for_new_window("msgcompose");
- mc.click(
- mc.eid("mail-notification-top", { tagName: "button", label: "Edit" })
- );
- rwc = wait_for_compose_window();
- rwc.keypress(null, "s", { shiftKey: false, accelKey: true });
- close_compose_window(rwc);
- msg = select_click_row(0);
- assert_equals(
- getMsgHeaders(msg)
- .get("")
- .charset.toUpperCase(),
- "UTF-8"
- );
- assert_equals(
- getMsgHeaders(msg, true)
- .get("")
- .trim(),
- nonASCII
- );
- press_delete(mc); // Delete message
-}
-
-function teardownModule(module) {
- Services.prefs.clearUserPref("mailnews.send_default_charset");
-}
deleted file mode 100644
--- a/mail/test/mozmill/composition/test-charset-upgrade.js
+++ /dev/null
@@ -1,251 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests that we do the right thing wrt. message encoding, especially when
- * all characters doesn't fit the selected charset.
- */
-
-"use strict";
-
-var {
- get_msg_source,
- open_compose_new_mail,
- setup_msg_contents,
- type_in_composer,
-} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
-var {
- assert_equals,
- assert_true,
- be_in_folder,
- get_special_folder,
- press_delete,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { plan_for_window_close, wait_for_window_close } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-var gDrafts;
-var gOutbox;
-
-function setupModule(module) {
- gDrafts = get_special_folder(Ci.nsMsgFolderFlags.Drafts, true);
- gOutbox = get_special_folder(Ci.nsMsgFolderFlags.Queue);
-
- // Ensure reply charset isn't UTF-8, otherwise there's no need to upgrade,
- // which is what this test tests.
- let str = Cc["@mozilla.org/pref-localizedstring;1"].createInstance(
- Ci.nsIPrefLocalizedString
- );
- str.data = "windows-1252";
- Services.prefs.setComplexValue(
- "mailnews.send_default_charset",
- Ci.nsIPrefLocalizedString,
- str
- );
-
- // Don't create paragraphs in the test.
- // When creating a paragraph, the test fails to retrieve the
- // original character set windows-1252. Until we understand why,
- // we run without paragraphs.
- Services.prefs.setBoolPref("mail.compose.default_to_paragraph", false);
-}
-
-/**
- * Test that if all characters don't fit the current charset selection,
- * we upgrade properly to UTF-8. In HTML composition.
- */
-function test_encoding_upgrade_html_compose() {
- Services.prefs.setBoolPref("mail.identity.default.compose_html", true);
- let compWin = open_compose_new_mail();
-
- setup_msg_contents(
- compWin,
- "someone@example.com",
- "encoding upgrade test - html mode",
- "so far, this is latin1\n"
- );
-
- // Ctrl+S = save as draft.
- compWin.keypress(null, "s", { shiftKey: false, accelKey: true });
-
- be_in_folder(gDrafts);
- let draftMsg = select_click_row(0);
-
- // Charset should still be the default.
- assert_equals(draftMsg.Charset, "windows-1252");
-
- // We could pass "windows-1252", but the message is ASCII.
- let draftMsgContent = get_msg_source(draftMsg);
- if (!draftMsgContent.includes('content="text/html; charset=windows-1252"')) {
- throw new Error(
- "Expected content type not in msg; draftMsgContent=" + draftMsgContent
- );
- }
-
- const CHINESE = "漢皇é‡è‰²æ€å‚¾åœ‹æ¼¢çš‡é‡è‰²æ€å‚¾åœ‹";
- type_in_composer(compWin, [
- "but now, we enter some chinese: " + CHINESE + "\n",
- ]);
-
- // Ctrl+U = Underline (so we can check multipart/alternative gets right,
- // without it html->plaintext conversion will it as send plain text only)
- compWin.keypress(null, "U", { shiftKey: false, accelKey: true });
-
- type_in_composer(compWin, ["content need to be upgraded to utf-8 now."]);
-
- // Ctrl+S = save as draft.
- compWin.keypress(null, "s", { shiftKey: false, accelKey: true });
-
- be_in_folder(gDrafts);
- let draftMsg2 = select_click_row(0);
- // Charset should have be upgraded to UTF-8.
- assert_equals(draftMsg2.Charset, "UTF-8");
-
- let draftMsg2Content = get_msg_source(draftMsg2, "UTF-8");
- if (!draftMsg2Content.includes('content="text/html; charset=UTF-8"')) {
- throw new Error(
- "Expected content type not in msg; draftMsg2Content=" + draftMsg2Content
- );
- }
-
- if (!draftMsg2Content.includes(CHINESE)) {
- throw new Error(
- "Chinese text not in msg; CHINESE=" +
- CHINESE +
- ", draftMsg2Content=" +
- draftMsg2Content
- );
- }
-
- plan_for_window_close(compWin);
- compWin.window.goDoCommand("cmd_sendLater");
- wait_for_window_close();
-
- be_in_folder(gOutbox);
- let outMsg = select_click_row(0);
- let outMsgContent = get_msg_source(outMsg, "UTF-8");
-
- // This message should be multipart/alternative.
- if (!outMsgContent.includes("Content-Type: multipart/alternative")) {
- throw new Error("Expected multipart/alternative; content=" + outMsgContent);
- }
-
- let chinesePlainIdx = outMsgContent.indexOf(CHINESE);
- assert_true(
- chinesePlainIdx > 0,
- "chinesePlainIdx=" + chinesePlainIdx + ", outMsgContent=" + outMsgContent
- );
-
- let chineseHTMLIdx = outMsgContent.indexOf(CHINESE, chinesePlainIdx);
- assert_true(
- chineseHTMLIdx > 0,
- "chineseHTMLIdx=" + chineseHTMLIdx + ", outMsgContent=" + outMsgContent
- );
-
- // Make sure the actual html also got the content type set correctly.
- if (!outMsgContent.includes('content="text/html; charset=UTF-8"')) {
- throw new Error(
- "Expected content type not in html; outMsgContent=" + outMsgContent
- );
- }
-
- press_delete(); // Delete the msg from Outbox.
-}
-
-/**
- * Test that if all characters don't fit the current charset selection,
- * we upgrade properly to UTF-8. In plaintext composition.
- */
-function test_encoding_upgrade_plaintext_compose() {
- Services.prefs.setBoolPref("mail.identity.default.compose_html", false);
- let compWin = open_compose_new_mail();
- Services.prefs.setBoolPref("mail.identity.default.compose_html", true);
-
- setup_msg_contents(
- compWin,
- "someone-else@example.com",
- "encoding upgrade test - plaintext",
- "this is plaintext latin1\n"
- );
-
- // Ctrl+S = Save as Draft.
- compWin.keypress(null, "s", { shiftKey: false, accelKey: true });
-
- be_in_folder(gDrafts);
- let draftMsg = select_click_row(0);
-
- // Charset should still be the default.
- assert_equals(draftMsg.Charset, "windows-1252");
-
- const CHINESE = "漢皇é‡è‰²æ€å‚¾åœ‹æ¼¢çš‡é‡è‰²æ€å‚¾åœ‹";
- type_in_composer(compWin, [
- "enter some plain text chinese: " + CHINESE,
- "content need to be upgraded to utf-8 now.",
- ]);
-
- // Ctrl+S = Save as Draft.
- compWin.keypress(null, "s", { shiftKey: false, accelKey: true });
-
- be_in_folder(gDrafts);
- let draftMsg2 = select_click_row(0);
- // Charset should have be upgraded to UTF-8.
- assert_equals(draftMsg2.Charset, "UTF-8");
-
- let draftMsg2Content = get_msg_source(draftMsg2, "UTF-8");
- if (draftMsg2Content.includes("<html>")) {
- throw new Error(
- "Plaintext draft contained <html>; " +
- "draftMsg2Content=" +
- draftMsg2Content
- );
- }
-
- if (!draftMsg2Content.includes(CHINESE)) {
- throw new Error(
- "Chinese text not in msg; CHINESE=" +
- CHINESE +
- ", draftMsg2Content=" +
- draftMsg2Content
- );
- }
-
- plan_for_window_close(compWin);
- compWin.window.goDoCommand("cmd_sendLater");
- wait_for_window_close();
-
- be_in_folder(gOutbox);
- let outMsg = select_click_row(0);
- let outMsgContent = get_msg_source(outMsg, "UTF-8");
-
- // This message should be text/plain;
- if (!outMsgContent.includes("Content-Type: text/plain")) {
- throw new Error("Expected text/plain; content=" + outMsgContent);
- }
-
- if (!outMsgContent.includes(CHINESE)) {
- throw new Error(
- "Chinese text not in msg; CHINESE=" +
- CHINESE +
- ", outMsgContent=" +
- outMsgContent
- );
- }
-
- press_delete(); // Delete the msg from Outbox.
-}
-
-function teardownModule(module) {
- Services.prefs.clearUserPref("mailnews.send_default_charset");
- Services.prefs.clearUserPref("mail.compose.default_to_paragraph");
- Services.prefs.clearUserPref("mail.identity.default.compose_html");
-}
deleted file mode 100644
--- a/mail/test/mozmill/composition/test-cp932-display.js
+++ /dev/null
@@ -1,38 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests that messages in cp932, Thunderbirds alias for Shift_JIS, are correctly displayed.
- */
-
-"use strict";
-
-var os = ChromeUtils.import("chrome://mozmill/content/stdlib/os.jsm");
-
-var { assert_true, open_message_from_file } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { close_window } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-function test_cp932_display() {
- let file = os.getFileForPath(
- os.abspath("./charset-cp932.eml", os.getFileForPath(__file__))
- );
- let msgc = open_message_from_file(file);
- let subjectText = msgc.e("expandedsubjectBox").textContent;
- let bodyText = msgc.e("messagepane").contentDocument.querySelector("body")
- .textContent;
- close_window(msgc);
-
- assert_true(
- subjectText.includes("ã“ã“ã«æœ¬æ–‡ãŒãã¾ã™ã€‚"),
- "Decoded cp932 text not found in message subject."
- );
- assert_true(
- bodyText.includes("ã“ã“ã«æœ¬æ–‡ãŒãã¾ã™ã€‚"),
- "Decoded cp932 text not found in message body."
- );
-}
deleted file mode 100644
--- a/mail/test/mozmill/composition/test-draft-identity.js
+++ /dev/null
@@ -1,302 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests that compose new message chooses the correct initial identity when
- * called from the context of an open composer.
- */
-
-"use strict";
-
-var { close_compose_window, open_compose_from_draft } = ChromeUtils.import(
- "resource://testing-common/mozmill/ComposeHelpers.jsm"
-);
-var {
- assert_equals,
- be_in_folder,
- get_special_folder,
- mc,
- press_delete,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var {
- assert_notification_displayed,
- wait_for_notification_to_show,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/NotificationBoxHelpers.jsm"
-);
-
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-var gDrafts;
-var gAccount;
-
-// The first identity should become the default in the account.
-var gIdentities = [
- { email: "x@example.invalid" },
- { email: "y@example.invalid", fullname: "User Y" },
- { email: "y@example.invalid", fullname: "User YY", label: "YY" },
- { email: "y+y@example.invalid", fullname: "User Y" },
- { email: "z@example.invalid", fullname: "User Z", label: "Label Z" },
- { email: "a+b@example.invalid", fullname: "User A" },
-];
-
-function setupModule(module) {
- // Now set up an account with some identities.
- let acctMgr = MailServices.accounts;
- gAccount = acctMgr.createAccount();
- gAccount.incomingServer = acctMgr.createIncomingServer(
- "nobody",
- "Draft Identity Testing",
- "pop3"
- );
-
- for (let id of gIdentities) {
- let identity = acctMgr.createIdentity();
- if ("email" in id) {
- identity.email = id.email;
- }
- if ("fullname" in id) {
- identity.fullName = id.fullname;
- }
- if ("label" in id) {
- identity.label = id.label;
- }
- gAccount.addIdentity(identity);
- id.key = identity.key;
- id.name = identity.identityName;
- }
-
- acctMgr.defaultAccount = gAccount;
-
- gDrafts = get_special_folder(Ci.nsMsgFolderFlags.Drafts, true);
-}
-
-/**
- * Create a new templated draft message in the drafts folder.
- *
- * @return {integer} The index (position) of the created message in the drafts folder.
- */
-function create_draft(aFrom, aIdKey) {
- let msgCount = gDrafts.getTotalMessages(false);
- let source =
- "From - Wed Mar 01 01:02:03 2017\n" +
- "X-Mozilla-Status: 0000\n" +
- "X-Mozilla-Status2: 00000000\n" +
- "X-Mozilla-Keys: \n" +
- "FCC: mailbox://nobody@Local%20Folders/Sent\n" +
- (aIdKey
- ? // prettier-ignore
- `X-Identity-Key: ${aIdKey}\n` +
- `X-Account-Key: ${gAccount.key}\n`
- : "") +
- `From: ${aFrom}\n` +
- "To: nobody@example.invalid\n" +
- "Subject: test!\n" +
- `Message-ID: <${msgCount}@example.invalid>\n` +
- "Date: Wed, 1 Mar 2017 01:02:03 +0100\n" +
- "X-Mozilla-Draft-Info: internal/draft; vcard=0; receipt=0; DSN=0; uuencode=0;\n" +
- " attachmentreminder=0; deliveryformat=4\n" +
- "MIME-Version: 1.0\n" +
- "Content-Type: text/plain; charset=utf-8\n" +
- "Content-Transfer-Encoding: 8bit\n" +
- "\n" +
- "Testing draft identity.\n";
-
- gDrafts.QueryInterface(Ci.nsIMsgLocalMailFolder).addMessage(source);
- let msgCountNew = gDrafts.getTotalMessages(false);
-
- assert_equals(msgCountNew, msgCount + 1);
- return msgCountNew - 1;
-}
-
-/**
- * Helper to check that a suitable From identity was set up in the given
- * composer window.
- *
- * @param cwc Compose window controller.
- * @param aIdentityKey The key of the expected identity.
- * @param aFrom The expected displayed From address.
- */
-function checkCompIdentity(cwc, aIdentityKey, aFrom) {
- assert_equals(
- cwc.window.getCurrentAccountKey(),
- gAccount.key,
- "The From account is not correctly selected"
- );
- assert_equals(
- cwc.window.getCurrentIdentityKey(),
- aIdentityKey,
- "The From identity is not correctly selected"
- );
- assert_equals(
- cwc.window.document.getElementById("msgIdentity").value,
- aFrom,
- "The From value was initialized to an unexpected value"
- );
-}
-
-/**
- * Bug 394216
- * Test that starting a new message from a draft with various combinations
- * of From and X-Identity-Key gets the expected initial identity selected.
- */
-function test_draft_identity_selection() {
- let tests = [
- // X-Identity-Key header exists:
- // 1. From header matches X-Identity-Key identity exactly
- {
- idIndex: 1,
- warning: false,
- draftIdKey: gIdentities[1].key,
- draftFrom: gIdentities[1].name,
- },
- // 2. From header similar to X-Identity-Key identity with +suffix appended
- {
- idIndex: 1,
- warning: false,
- draftIdKey: gIdentities[1].key,
- draftFrom: gIdentities[1].name.replace("y@", "y+x@"),
- },
- // 3. X-Identity-Key identity similar to From header with +suffix appended
- {
- idIndex: 5,
- warning: false,
- draftIdKey: gIdentities[5].key,
- draftFrom: gIdentities[5].name.replace("a+b@", "a@"),
- },
-
- // From header not similar to existing X-Identity-Key identity:
- // 4. From header not even containing an email address
- {
- idIndex: 5,
- warning: false,
- draftIdKey: gIdentities[5].key,
- draftFrom: "User",
- from: "User <>",
- },
- // 5. no matching identity exists
- {
- idIndex: 1,
- warning: true,
- draftIdKey: gIdentities[1].key,
- draftFrom: "New User <modified@sender.invalid>",
- },
- // 6. 1 matching identity exists
- {
- idIndex: 4,
- warning: false,
- draftIdKey: gIdentities[4].key,
- draftFrom: "New User <" + gIdentities[4].email + ">",
- },
- // 7. 2 or more matching identities exist
- {
- idIndex: 1,
- warning: true,
- draftIdKey: gIdentities[0].key,
- draftFrom: gIdentities[1].name.replace("User Y", "User YZ"),
- },
-
- // No X-Identity-Key header:
- // 8. no matching identity exists
- // This is a 'foreign draft' in which case we won't preserve the From value
- // and set it from the default identity.
- {
- idIndex: 0,
- warning: true,
- draftFrom: "Unknown <unknown@nowhere.invalid>",
- from: gIdentities[0].name,
- },
- // 9. From header matches default identity
- { idIndex: 0, warning: false, draftFrom: gIdentities[0].name },
- // 10. From header matches some other identity
- { idIndex: 5, warning: false, draftFrom: gIdentities[5].name },
- // 11. From header matches identity with suffix
- { idIndex: 3, warning: false, draftFrom: gIdentities[3].name },
- // 12. From header matches 2 identities
- {
- idIndex: 1,
- warning: true,
- draftFrom: gIdentities[1].email,
- from: gIdentities[1].name,
- },
- ];
-
- for (let test of tests) {
- test.draftIndex = create_draft(test.draftFrom, test.draftIdKey);
- }
-
- for (let test of tests) {
- dump("Running draft identity test" + tests.indexOf(test) + "\n");
- be_in_folder(gDrafts);
- select_click_row(test.draftIndex);
-
- let cwc = open_compose_from_draft();
- checkCompIdentity(
- cwc,
- gIdentities[test.idIndex].key,
- test.from ? test.from : test.draftFrom
- );
- if (test.warning) {
- wait_for_notification_to_show(
- cwc,
- "compose-notification-bottom",
- "identityWarning"
- );
- } else {
- assert_notification_displayed(
- cwc,
- "compose-notification-bottom",
- "identityWarning",
- false
- );
- }
-
- close_compose_window(cwc, false);
- }
- /*
- // TODO: fix this in bug 1238264, the identity selector does not properly close.
- // Open a draft again that shows the notification.
- be_in_folder(gDrafts);
- select_click_row(tests[tests.length-1].draftIndex);
- let cwc = open_compose_from_draft();
- wait_for_notification_to_show(cwc, "compose-notification-bottom",
- "identityWarning");
- // Notification should go away when another identity is chosen.
- cwc.click(cwc.eid("msgIdentity"));
- cwc.click_menus_in_sequence(cwc.e("msgIdentityPopup"),
- [ { identitykey: gIdentities[0].key } ]);
-
- wait_for_notification_to_stop(cwc, "compose-notification-bottom",
- "identityWarning");
- close_compose_window(cwc, false);
-*/
-}
-test_draft_identity_selection.EXCLUDED_PLATFORMS = ["darwin"]; // See bug 1413851.
-
-function teardownModule(module) {
- for (let id = 1; id < gIdentities.length; id++) {
- gAccount.removeIdentity(
- MailServices.accounts.getIdentity(gIdentities[id].key)
- );
- }
-
- // The last identity of an account can't be removed so clear all its prefs
- // which effectively destroys it.
- MailServices.accounts.getIdentity(gIdentities[0].key).clearAllValues();
- MailServices.accounts.removeAccount(gAccount);
- gAccount = null;
-
- // Clear our drafts.
- be_in_folder(gDrafts);
- let draftCount;
- while ((draftCount = gDrafts.getTotalMessages(false)) > 0) {
- press_delete();
- mc.waitFor(() => gDrafts.getTotalMessages(false) < draftCount);
- }
-}
deleted file mode 100644
--- a/mail/test/mozmill/composition/test-drafts.js
+++ /dev/null
@@ -1,328 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests draft related functionality:
- * - that we don't allow opening multiple copies of a draft.
- */
-
-"use strict";
-
-var utils = ChromeUtils.import("chrome://mozmill/content/modules/utils.jsm");
-
-var {
- close_compose_window,
- get_compose_body,
- get_msg_source,
- open_compose_new_mail,
- setup_msg_contents,
- wait_for_compose_window,
-} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
-var {
- assert_equals,
- assert_true,
- be_in_folder,
- get_special_folder,
- make_new_sets_in_folder,
- mc,
- press_delete,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { wait_for_notification_to_show } = ChromeUtils.import(
- "resource://testing-common/mozmill/NotificationBoxHelpers.jsm"
-);
-var { plan_for_new_window, wait_for_window_focused } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-var kBoxId = "mail-notification-top";
-var draftsFolder;
-
-function setupModule(module) {
- draftsFolder = get_special_folder(Ci.nsMsgFolderFlags.Drafts, true);
-}
-
-/**
- * Bug 349547.
- * Tests that we only open one compose window for one instance of a draft.
- */
-function test_open_draft_again() {
- make_new_sets_in_folder(draftsFolder, [{ count: 1 }]);
- be_in_folder(draftsFolder);
- select_click_row(0);
-
- // Wait for the notification with the Edit button.
- wait_for_notification_to_show(mc, kBoxId, "draftMsgContent");
-
- plan_for_new_window("msgcompose");
- mc.click(mc.eid(kBoxId, { tagName: "button", label: "Edit" }));
- let cwc = wait_for_compose_window();
-
- let cwins = 0;
- let e = Services.wm.getEnumerator("msgcompose");
- while (e.hasMoreElements()) {
- e.getNext();
- cwins++;
- }
-
- // click edit in main win again
- mc.click(mc.eid(kBoxId, { tagName: "button", label: "Edit" }));
-
- mc.sleep(1000); // wait a sec to see if it caused a new window
-
- assert_true(
- Services.ww.activeWindow == cwc.window,
- "the original draft composition window should have got focus (again)"
- );
-
- let cwins2 = 0;
- let e2 = Services.wm.getEnumerator("msgcompose");
- while (e2.hasMoreElements()) {
- e2.getNext();
- cwins2++;
- }
-
- assert_true(cwins2 > 0, "No compose window open!");
- assert_equals(cwins, cwins2, "The number of compose windows changed!");
-
- // Type something and save, then check that we only have one draft.
- cwc.type(cwc.eid("content-frame"), "Hello!");
- cwc.keypress(null, "s", { shiftKey: false, accelKey: true });
- close_compose_window(cwc);
- assert_equals(draftsFolder.getTotalMessages(false), 1);
-
- press_delete(mc); // clean up after ourselves
-}
-
-/**
- * Bug 1202165
- * Test that the user set delivery format is preserved in a draft message.
- */
-function internal_check_delivery_format(editDraft) {
- let cwc = open_compose_new_mail();
-
- setup_msg_contents(
- cwc,
- "test@example.invalid",
- "Testing storing of the composition properties in the draft!",
- "Hello!"
- );
-
- // Select our wanted format.
- if (!mc.mozmillModule.isMac) {
- cwc.click(cwc.eid("optionsMenu"));
- cwc.click_menus_in_sequence(cwc.e("optionsMenuPopup"), [
- { id: "outputFormatMenu" },
- { id: "format_both" },
- ]);
- } else {
- // On OS X the main menu seems not accessible for clicking from mozmill.
- assert_true(
- cwc
- .e("outputFormatMenu")
- .getAttribute("oncommand")
- .startsWith("OutputFormatMenuSelect(")
- );
- cwc.window.OutputFormatMenuSelect(cwc.e("format_both"));
- }
-
- /**
- * Check if the right format is selected in the menu.
- *
- * @param aMenuItemId The id of the menuitem expected to be selected.
- * @param aValue A value of nsIMsgCompSendFormat constants of the expected selected format.
- */
- function assert_format_value(aMenuItemId, aValue) {
- if (!mc.mozmillModule.isMac) {
- cwc.click(cwc.eid("optionsMenu"));
- let formatMenu = cwc.click_menus_in_sequence(
- cwc.e("optionsMenuPopup"),
- [{ id: "outputFormatMenu" }],
- true
- );
- let formatItem = cwc
- .e("outputFormatMenuPopup")
- .querySelector("[name=output_format][checked=true]");
- assert_equals(formatItem.id, aMenuItemId);
- cwc.close_popup_sequence(formatMenu);
- } else {
- assert_equals(cwc.window.gSendFormat, aValue);
- }
- }
-
- cwc.window.SaveAsDraft();
- utils.waitFor(
- () => !cwc.window.gSaveOperationInProgress && !cwc.window.gWindowLock,
- "Saving of draft did not finish"
- );
- wait_for_window_focused(cwc.window);
-
- close_compose_window(cwc);
-
- // Open a new composition see if the menu is again at default value, not the one
- // chosen above.
- cwc = open_compose_new_mail();
-
- assert_format_value("format_auto", Ci.nsIMsgCompSendFormat.AskUser);
-
- close_compose_window(cwc);
-
- be_in_folder(draftsFolder);
- select_click_row(0);
-
- // Wait for the notification with the Edit button.
- wait_for_notification_to_show(mc, kBoxId, "draftMsgContent");
-
- plan_for_new_window("msgcompose");
- if (editDraft) {
- // Trigger "edit draft".
- mc.click(mc.eid(kBoxId, { tagName: "button", label: "Edit" }));
- } else {
- // Trigger "edit as new" resulting in template processing.
- mc.keypress(null, "e", { shiftKey: false, accelKey: true });
- }
- cwc = wait_for_compose_window();
-
- // Check if format value was restored.
- assert_format_value("format_both", Ci.nsIMsgCompSendFormat.Both);
-
- close_compose_window(cwc);
-
- press_delete(mc); // clean up the created draft
-}
-
-function test_save_delivery_format_with_edit_draft() {
- internal_check_delivery_format(true);
-}
-
-function test_save_delivery_format_with_edit_template() {
- internal_check_delivery_format(false);
-}
-
-/**
- * Tests that 'Edit as New' leaves the original message in drafts folder.
- */
-function test_edit_as_new_in_draft() {
- make_new_sets_in_folder(draftsFolder, [{ count: 1 }]);
- be_in_folder(draftsFolder);
-
- assert_equals(draftsFolder.getTotalMessages(false), 1);
-
- select_click_row(0);
-
- // Wait for the notification with the Edit button.
- wait_for_notification_to_show(mc, kBoxId, "draftMsgContent");
-
- plan_for_new_window("msgcompose");
- mc.keypress(null, "e", { shiftKey: false, accelKey: true });
- let cwc = wait_for_compose_window();
-
- cwc.type(cwc.eid("content-frame"), "Hello!");
- cwc.keypress(null, "s", { shiftKey: false, accelKey: true });
-
- close_compose_window(cwc);
- assert_equals(draftsFolder.getTotalMessages(false), 2);
-
- // Clean up the created drafts and count again.
- press_delete(mc);
- press_delete(mc);
- assert_equals(draftsFolder.getTotalMessages(false), 0);
-}
-
-/**
- * Tests Content-Language header.
- */
-function test_content_language_header() {
- let cwc = open_compose_new_mail();
-
- setup_msg_contents(
- cwc,
- "test@example.invalid",
- "Testing Content-Language header",
- "Hello, we speak en-US"
- );
-
- cwc.window.SaveAsDraft();
- utils.waitFor(
- () => !cwc.window.gSaveOperationInProgress && !cwc.window.gWindowLock,
- "Saving of draft did not finish"
- );
- wait_for_window_focused(cwc.window);
- close_compose_window(cwc);
-
- be_in_folder(draftsFolder);
- let draftMsg = select_click_row(0);
- let draftMsgContent = get_msg_source(draftMsg);
-
- // Check for a single line that contains our header.
- if (
- !draftMsgContent
- .split("\n")
- .some(line => line.trim() == "Content-Language: en-US")
- ) {
- assert_true(false, "Failed to find Content-Language: en-US");
- }
-
- // Clean up the created draft.
- press_delete(mc);
-}
-
-/**
- * Tests space stuffing of plaintext message.
- */
-function test_remove_space_stuffing_format_flowed() {
- // Prepare for plaintext email.
- let oldHtmlPref = Services.prefs.getBoolPref(
- "mail.identity.default.compose_html"
- );
- Services.prefs.setBoolPref("mail.identity.default.compose_html", false);
-
- let cwc = open_compose_new_mail();
-
- setup_msg_contents(
- cwc,
- "test@example.invalid",
- "Testing space stuffing in plain text email",
- "NoSpace\n OneSpace\n TwoSpaces"
- );
-
- cwc.window.SaveAsDraft();
- utils.waitFor(
- () => !cwc.window.gSaveOperationInProgress && !cwc.window.gWindowLock,
- "Saving of draft did not finish"
- );
- wait_for_window_focused(cwc.window);
-
- close_compose_window(cwc);
-
- be_in_folder(draftsFolder);
-
- select_click_row(0);
-
- // Wait for the notification with the Edit button.
- wait_for_notification_to_show(mc, kBoxId, "draftMsgContent");
-
- plan_for_new_window("msgcompose");
- mc.click(mc.eid(kBoxId, { tagName: "button", label: "Edit" }));
- cwc = wait_for_compose_window();
-
- let bodyText = get_compose_body(cwc).innerHTML;
- if (!bodyText.includes("NoSpace<br> OneSpace<br> TwoSpaces")) {
- assert_true(false, "Something went wrong with space stuffing");
- }
-
- // Clean up the created draft.
- press_delete(mc);
-
- Services.prefs.setBoolPref("mail.identity.default.compose_html", oldHtmlPref);
-}
-
-function teardownModule() {}
deleted file mode 100644
--- a/mail/test/mozmill/composition/test-eml-actions.js
+++ /dev/null
@@ -1,171 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests that actions such as replying to an .eml works properly.
- */
-
-"use strict";
-
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-var os = ChromeUtils.import("chrome://mozmill/content/stdlib/os.jsm");
-
-var {
- close_compose_window,
- get_compose_body,
- open_compose_with_forward,
- open_compose_with_reply,
-} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
-var {
- assert_equals,
- be_in_folder,
- get_special_folder,
- open_message_from_file,
- press_delete,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { close_window } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-var gDrafts;
-
-function setupModule(module) {
- gDrafts = get_special_folder(Ci.nsMsgFolderFlags.Drafts, true);
-}
-
-/**
- * Test that replying to an opened .eml message works, and that the reply can
- * be saved as a draft.
- */
-function test_reply_to_eml_save_as_draft() {
- // Open an .eml file.
- let file = os.getFileForPath(
- os.abspath("./testmsg.eml", os.getFileForPath(__file__))
- );
- let msgc = open_message_from_file(file);
-
- let replyWin = open_compose_with_reply(msgc);
-
- // Ctrl+S saves as draft.
- replyWin.keypress(null, "s", { shiftKey: false, accelKey: true });
-
- // Drafts folder should exist now.
- be_in_folder(gDrafts);
- let draftMsg = select_click_row(0);
- if (!draftMsg) {
- throw new Error("No draft saved!");
- }
- press_delete(); // Delete the draft.
-
- close_compose_window(replyWin); // close compose window
- close_window(msgc); // close base .eml message
-}
-
-/**
- * Test that forwarding an opened .eml message works, and that the forward can
- * be saved as a draft.
- */
-function test_forward_eml_save_as_draft() {
- // Open an .eml file.
- let file = os.getFileForPath(
- os.abspath("./testmsg.eml", os.getFileForPath(__file__))
- );
- let msgc = open_message_from_file(file);
-
- let replyWin = open_compose_with_forward(msgc);
-
- // Ctrl+S saves as draft.
- replyWin.keypress(null, "s", { shiftKey: false, accelKey: true });
-
- // Drafts folder should exist now.
- be_in_folder(gDrafts);
- let draftMsg = select_click_row(0);
- if (!draftMsg) {
- throw new Error("No draft saved!");
- }
- press_delete(); // Delete the draft.
-
- close_compose_window(replyWin); // close compose window
- close_window(msgc); // close base .eml message
-}
-
-/**
- * Test that MIME encoded subject is decoded when replying to an opened .eml.
- */
-function test_reply_eml_subject() {
- // Open an .eml file whose subject is encoded.
- let file = os.getFileForPath(
- os.abspath("./mime-encoded-subject.eml", os.getFileForPath(__file__))
- );
- let msgc = open_message_from_file(file);
-
- let replyWin = open_compose_with_reply(msgc);
-
- assert_equals(replyWin.e("msgSubject").value, "Re: \u2200a\u220aA");
- close_compose_window(replyWin); // close compose window
- close_window(msgc); // close base .eml message
-}
-
-/**
- * Test that replying to a base64 encoded .eml works.
- */
-function test_reply_to_base64_eml() {
- // Open an .eml file.
- let file = os.getFileForPath(
- os.abspath("./base64-encoded-msg.eml", os.getFileForPath(__file__))
- );
- let msgc = open_message_from_file(file);
-
- let compWin = open_compose_with_reply(msgc);
-
- let bodyText = get_compose_body(compWin).textContent;
- const message = "You have decoded this text from base64.";
- if (!bodyText.includes(message)) {
- throw new Error(
- "body text didn't contain the decoded text; message=" +
- message +
- ", bodyText=" +
- bodyText
- );
- }
-
- close_compose_window(compWin);
- close_window(msgc);
-}
-
-/**
- * Test that forwarding a base64 encoded .eml works.
- */
-function test_forward_base64_eml() {
- // Open an .eml file.
- let file = os.getFileForPath(
- os.abspath("./base64-encoded-msg.eml", os.getFileForPath(__file__))
- );
- let msgc = open_message_from_file(file);
-
- let compWin = open_compose_with_forward(msgc);
-
- let bodyText = get_compose_body(compWin).textContent;
- const message = "You have decoded this text from base64.";
- if (!bodyText.includes(message)) {
- throw new Error(
- "body text didn't contain the decoded text; message=" +
- message +
- ", bodyText=" +
- bodyText
- );
- }
-
- close_compose_window(compWin);
- close_window(msgc);
-}
deleted file mode 100644
--- a/mail/test/mozmill/composition/test-focus.js
+++ /dev/null
@@ -1,93 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test that cycling through the focus of the 3pane's panes works correctly.
- */
-
-"use strict";
-
-var {
- add_attachments,
- close_compose_window,
- open_compose_new_mail,
-} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
-var { assert_equals, mc } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-/**
- * Check that it's possible to cycle through the compose window's important
- * elements forward and backward.
- *
- * @param controller the compose window controller
- * @param attachmentsExpanded true if the attachment pane is expanded
- * @param ctrlTab true if we should use Ctrl+Tab to cycle, false if we should
- * use F6
- */
-function check_element_cycling(controller, attachmentsExpanded, ctrlTab) {
- let addressingElement = controller.e("toAddrInput");
- let subjectElement = controller.e("msgSubject");
- let attachmentElement = controller.e("attachmentBucket");
- let contentElement = controller.window.content;
- let identityElement = controller.e("msgIdentity");
-
- let key = ctrlTab ? "VK_TAB" : "VK_F6";
-
- // We start on the addressing widget and go from there.
-
- controller.keypress(null, key, { ctrlKey: ctrlTab });
- assert_equals(subjectElement, controller.window.WhichElementHasFocus());
- if (attachmentsExpanded) {
- controller.keypress(null, key, { ctrlKey: ctrlTab });
- assert_equals(attachmentElement, controller.window.WhichElementHasFocus());
- }
- controller.keypress(null, key, { ctrlKey: ctrlTab });
- assert_equals(contentElement, controller.window.WhichElementHasFocus());
- controller.keypress(null, key, { ctrlKey: ctrlTab });
- assert_equals(identityElement, controller.window.WhichElementHasFocus());
- controller.keypress(null, key, { ctrlKey: ctrlTab });
- mc.sleep(0); // Focusing the addressing element happens in a timeout...
- assert_equals(addressingElement, controller.window.WhichElementHasFocus());
-
- controller.keypress(null, key, { ctrlKey: ctrlTab, shiftKey: true });
- assert_equals(identityElement, controller.window.WhichElementHasFocus());
- controller.keypress(null, key, { ctrlKey: ctrlTab, shiftKey: true });
- assert_equals(contentElement, controller.window.WhichElementHasFocus());
- if (attachmentsExpanded) {
- controller.keypress(null, key, { ctrlKey: ctrlTab, shiftKey: true });
- assert_equals(attachmentElement, controller.window.WhichElementHasFocus());
- }
- controller.keypress(null, key, { ctrlKey: ctrlTab, shiftKey: true });
- assert_equals(subjectElement, controller.window.WhichElementHasFocus());
- controller.keypress(null, key, { ctrlKey: ctrlTab, shiftKey: true });
- mc.sleep(0); // Focusing the addressing element happens in a timeout...
- assert_equals(addressingElement, controller.window.WhichElementHasFocus());
-}
-
-function test_f6_no_attachment() {
- let cwc = open_compose_new_mail();
- check_element_cycling(cwc, false, false);
- close_compose_window(cwc);
-}
-
-function test_f6_attachment() {
- let cwc = open_compose_new_mail();
- add_attachments(cwc, "http://www.mozilla.org/");
- check_element_cycling(cwc, true, false);
- close_compose_window(cwc);
-}
-
-function test_ctrl_tab_no_attachment() {
- let cwc = open_compose_new_mail();
- check_element_cycling(cwc, false, true);
- close_compose_window(cwc);
-}
-
-function test_ctrl_tab_attachment() {
- let cwc = open_compose_new_mail();
- add_attachments(cwc, "http://www.mozilla.org/");
- check_element_cycling(cwc, true, true);
- close_compose_window(cwc);
-}
deleted file mode 100644
--- a/mail/test/mozmill/composition/test-forward-headers.js
+++ /dev/null
@@ -1,175 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests that headers like References and X-Forwarded-Message-Id are
- * set properly when forwarding messages.
- */
-
-"use strict";
-
-var {
- assert_previous_text,
- get_compose_body,
- open_compose_with_forward,
- open_compose_with_forward_as_attachments,
-} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
-var {
- add_sets_to_folders,
- assert_equals,
- assert_true,
- be_in_folder,
- create_folder,
- create_thread,
- get_special_folder,
- mc,
- press_delete,
- select_click_row,
- select_shift_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { to_mime_message } = ChromeUtils.import(
- "resource://testing-common/mozmill/MessageHelpers.jsm"
-);
-var {
- plan_for_modal_dialog,
- plan_for_window_close,
- wait_for_modal_dialog,
- wait_for_window_close,
-} = ChromeUtils.import("resource://testing-common/mozmill/WindowHelpers.jsm");
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var cwc = null; // compose window controller
-var folder;
-var gDrafts;
-
-function setupModule(module) {
- folder = create_folder("Test");
- let thread1 = create_thread(10);
- add_sets_to_folders([folder], [thread1]);
-
- gDrafts = get_special_folder(Ci.nsMsgFolderFlags.Drafts, true);
-
- // Don't create paragraphs in the test.
- // The test checks for the first DOM node and expects a text and not
- // a paragraph.
- Services.prefs.setBoolPref("mail.compose.default_to_paragraph", false);
-}
-
-function teardownModule(module) {
- Services.prefs.clearUserPref("mail.compose.default_to_paragraph");
-}
-
-function forward_selected_messages_and_go_to_drafts_folder(f) {
- const kText = "Hey check out this megalol link";
- // opening a new compose window
- cwc = f(mc);
- cwc.type(cwc.eid("content-frame"), kText);
-
- let mailBody = get_compose_body(cwc);
- assert_previous_text(mailBody.firstChild, [kText]);
-
- plan_for_window_close(cwc);
- // mwc is modal window controller
- plan_for_modal_dialog("commonDialogWindow", function click_save(mwc) {
- // accept saving
- mwc.window.document
- .querySelector("dialog")
- .getButton("accept")
- .doCommand();
- });
-
- // quit -> do you want to save ?
- cwc.window.goDoCommand("cmd_close");
- // wait for the modal dialog to return
- wait_for_modal_dialog();
- // Actually quit the window.
- wait_for_window_close();
-
- // Visit the existing Drafts folder.
- be_in_folder(gDrafts);
-}
-
-function test_forward_inline() {
- be_in_folder(folder);
- // original message header
- let oMsgHdr = select_click_row(0);
-
- forward_selected_messages_and_go_to_drafts_folder(open_compose_with_forward);
-
- // forwarded message header
- let fMsgHdr = select_click_row(0);
-
- assert_true(
- fMsgHdr.numReferences > 0,
- "No References Header in forwarded msg."
- );
- assert_equals(
- fMsgHdr.getStringReference(0),
- oMsgHdr.messageId,
- "The forwarded message should have References: = Message-Id: of the original msg"
- );
-
- // test for x-forwarded-message id and exercise the js mime representation as
- // well
- to_mime_message(fMsgHdr, null, function(aMsgHdr, aMimeMsg) {
- assert_equals(
- aMimeMsg.headers["x-forwarded-message-id"],
- "<" + oMsgHdr.messageId + ">"
- );
- assert_equals(aMimeMsg.headers.references, "<" + oMsgHdr.messageId + ">");
- });
- press_delete(mc);
-}
-
-function test_forward_as_attachments() {
- be_in_folder(folder);
- // original message header
- let oMsgHdr0 = select_click_row(0);
- let oMsgHdr1 = select_click_row(1);
- select_shift_click_row(0);
-
- forward_selected_messages_and_go_to_drafts_folder(
- open_compose_with_forward_as_attachments
- );
-
- // forwarded message header
- let fMsgHdr = select_click_row(0);
-
- assert_true(
- fMsgHdr.numReferences > 0,
- "No References Header in forwarded msg."
- );
- assert_true(
- fMsgHdr.numReferences > 1,
- "Only one References Header in forwarded msg."
- );
- assert_equals(
- fMsgHdr.getStringReference(1),
- oMsgHdr1.messageId,
- "The forwarded message should have References: = Message-Id: of the original msg#1"
- );
- assert_equals(
- fMsgHdr.getStringReference(0),
- oMsgHdr0.messageId,
- "The forwarded message should have References: = Message-Id: of the original msg#0"
- );
-
- // test for x-forwarded-message id and exercise the js mime representation as
- // well
- to_mime_message(fMsgHdr, null, function(aMsgHdr, aMimeMsg) {
- assert_equals(
- aMimeMsg.headers["x-forwarded-message-id"],
- "<" + oMsgHdr0.messageId + "> <" + oMsgHdr1.messageId + ">"
- );
- assert_equals(
- aMimeMsg.headers.references,
- "<" + oMsgHdr0.messageId + "> <" + oMsgHdr1.messageId + ">"
- );
- });
-
- press_delete(mc);
-}
deleted file mode 100644
--- a/mail/test/mozmill/composition/test-forward-rfc822-attach.js
+++ /dev/null
@@ -1,77 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests that attached messages (message/rfc822) are correctly sent.
- * It's easiest to test the forward case.
- */
-
-"use strict";
-
-var os = ChromeUtils.import("chrome://mozmill/content/stdlib/os.jsm");
-
-var {
- close_compose_window,
- get_msg_source,
- open_compose_with_forward_as_attachments,
-} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
-var {
- assert_true,
- be_in_folder,
- get_special_folder,
- mc,
- open_message_from_file,
- press_delete,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { close_window } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-var gDrafts;
-
-function setupModule(module) {
- gDrafts = get_special_folder(Ci.nsMsgFolderFlags.Drafts, true);
-}
-
-function forwardDirect(aFilePath, aExpectedText) {
- let file = os.getFileForPath(
- os.abspath(aFilePath, os.getFileForPath(__file__))
- );
- let msgc = open_message_from_file(file);
-
- let cwc = open_compose_with_forward_as_attachments(msgc);
-
- // Ctrl+S saves as draft.
- cwc.keypress(null, "s", { shiftKey: false, accelKey: true });
-
- close_compose_window(cwc);
- close_window(msgc);
-
- be_in_folder(gDrafts);
- let draftMsg = select_click_row(0);
-
- let draftMsgContent = get_msg_source(draftMsg);
-
- if (!draftMsgContent.includes(aExpectedText)) {
- assert_true(false, "Failed to find expected text");
- }
-
- press_delete(mc); // clean up the created draft
-}
-
-function test_forwarding_long_html_line_as_attachment() {
- forwardDirect("./long-html-line.eml", "We like writing long lines.");
-}
-
-function test_forwarding_feed_message_as_attachment() {
- forwardDirect("./feed-message.eml", "We like using linefeeds only.");
-}
deleted file mode 100644
--- a/mail/test/mozmill/composition/test-forward-utf8.js
+++ /dev/null
@@ -1,138 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests that UTF-8 messages are correctly forwarded.
- */
-
-"use strict";
-
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-var os = ChromeUtils.import("chrome://mozmill/content/stdlib/os.jsm");
-
-var {
- close_compose_window,
- get_compose_body,
- open_compose_with_forward,
-} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
-var {
- assert_selected_and_displayed,
- assert_true,
- be_in_folder,
- create_folder,
- mc,
- open_message_from_file,
- press_delete,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { close_window } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-var folderToSendFrom;
-
-function setupModule(module) {
- folderToSendFrom = create_folder("FolderWithUTF8");
-}
-
-function check_content(window) {
- let mailBody = get_compose_body(window);
-
- let node = mailBody.firstChild;
- while (node) {
- if (node.classList.contains("moz-forward-container")) {
- // We found the forward container. Let's look for our text.
- node = node.firstChild;
- while (node) {
- // We won't find the exact text in the DOM but we'll find our string.
- if (node.nodeName == "#text" && node.nodeValue.includes("áóúäöüß")) {
- return;
- }
- node = node.nextSibling;
- }
- // Text not found in the forward container.
- assert_true(false, "Failed to find forwarded text");
- return;
- }
- node = node.nextSibling;
- }
-
- assert_true(false, "Failed to find forward container");
-}
-
-function forwardDirect(aFilePath) {
- let file = os.getFileForPath(
- os.abspath(aFilePath, os.getFileForPath(__file__))
- );
- let msgc = open_message_from_file(file);
-
- let cwc = open_compose_with_forward(msgc);
-
- check_content(cwc);
-
- close_compose_window(cwc);
- close_window(msgc);
-}
-
-function forwardViaFolder(aFilePath) {
- be_in_folder(folderToSendFrom);
-
- let file = os.getFileForPath(
- os.abspath(aFilePath, os.getFileForPath(__file__))
- );
- let msgc = open_message_from_file(file);
-
- // Copy the message to a folder.
- let documentChild = msgc.e("messagepane").contentDocument.firstChild;
- msgc.rightClick(new elib.Elem(documentChild));
- msgc.click_menus_in_sequence(msgc.e("mailContext"), [
- { id: "mailContext-copyMenu" },
- { label: "Local Folders" },
- { label: "FolderWithUTF8" },
- ]);
- close_window(msgc);
-
- let msg = select_click_row(0);
- assert_selected_and_displayed(mc, msg);
-
- let fwdWin = open_compose_with_forward();
-
- check_content(fwdWin);
-
- close_compose_window(fwdWin);
-
- press_delete(mc);
-}
-
-function test_utf8_forwarding_from_opened_file() {
- forwardDirect("./content-utf8-rel-only.eml");
- forwardDirect("./content-utf8-rel-alt.eml");
- forwardDirect("./content-utf8-alt-rel.eml");
-}
-
-function test_utf8_forwarding_from_via_folder() {
- forwardViaFolder("./content-utf8-rel-only.eml");
- forwardViaFolder("./content-utf8-rel-alt.eml"); // Also tests HTML part without <html> tag.
- forwardViaFolder("./content-utf8-alt-rel.eml"); // Also tests <html attr>.
- forwardViaFolder("./content-utf8-alt-rel2.eml"); // Also tests content before <html>.
-
- // Repeat the last three in simple HTML view.
- Services.prefs.setIntPref("mailnews.display.html_as", 3);
- forwardViaFolder("./content-utf8-rel-alt.eml"); // Also tests HTML part without <html> tag.
- forwardViaFolder("./content-utf8-alt-rel.eml"); // Also tests <html attr>.
- forwardViaFolder("./content-utf8-alt-rel2.eml"); // Also tests content before <html>.
-}
-
-function teardownModule() {
- Services.prefs.clearUserPref("mailnews.display.html_as");
-}
deleted file mode 100644
--- a/mail/test/mozmill/composition/test-forwarded-content.js
+++ /dev/null
@@ -1,63 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests that forwarded content is ok.
- */
-
-"use strict";
-
-var { close_compose_window, open_compose_with_forward } = ChromeUtils.import(
- "resource://testing-common/mozmill/ComposeHelpers.jsm"
-);
-var {
- add_message_to_folder,
- assert_selected_and_displayed,
- be_in_folder,
- create_folder,
- create_message,
- mc,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var folder = null;
-
-function setupModule(module) {
- folder = create_folder("Forward Content Testing");
- add_message_to_folder(
- folder,
- create_message({
- subject: "something like <foo@example>",
- body: { body: "Testing bug 397021!" },
- })
- );
-}
-
-/**
- * Test that the subject is set properly in the forwarded message content
- * when you hit forward.
- */
-function test_forwarded_subj() {
- be_in_folder(folder);
-
- let msg = select_click_row(0);
- assert_selected_and_displayed(mc, msg);
-
- let fwdWin = open_compose_with_forward();
-
- let headerTableText = fwdWin
- .e("content-frame")
- .contentDocument.querySelector("table").textContent;
- if (!headerTableText.includes(msg.mime2DecodedSubject)) {
- throw new Error(
- "Subject not set correctly in header table: subject=" +
- msg.mime2DecodedSubject +
- ", header table text=" +
- headerTableText
- );
- }
- close_compose_window(fwdWin);
-}
deleted file mode 100644
--- a/mail/test/mozmill/composition/test-forwarded-eml-actions.js
+++ /dev/null
@@ -1,164 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests that actions such as replying and forwarding works correctly from
- * an .eml message that's attached to another mail.
- */
-
-"use strict";
-
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-
-var {
- close_compose_window,
- get_compose_body,
- wait_for_compose_window,
-} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
-var {
- assert_selected_and_displayed,
- be_in_folder,
- create_folder,
- mc,
- select_click_row,
- wait_for_message_display_completion,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var {
- close_window,
- plan_for_new_window,
- wait_for_new_window,
-} = ChromeUtils.import("resource://testing-common/mozmill/WindowHelpers.jsm");
-
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-var folder;
-
-var msgsubject = "mail client suggestions";
-var msgbodyA = "know of a good email client?";
-var msgbodyB = "hi, i think you may know of an email client to recommend?";
-
-var setupModule = function(module) {
- folder = create_folder("FwdedEmlTest");
-
- let source =
- "From - Mon Apr 16 22:55:33 2012\n" +
- "Date: Mon, 16 Apr 2012 22:55:33 +0300\n" +
- "From: Mr Example <example@invalid>\n" +
- "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120331 Thunderbird/14.0a1\n" +
- "MIME-Version: 1.0\n" +
- "To: example@invalid\n" +
- "Subject: Fwd: " +
- msgsubject +
- "\n" +
- "References: <4F8C78F5.4000704@invalid>\n" +
- "In-Reply-To: <4F8C78F5.4000704@invalid>\n" +
- "X-Forwarded-Message-Id: <4F8C78F5.4000704@invalid>\n" +
- "Content-Type: multipart/mixed;\n" +
- ' boundary="------------080806020206040800000503"\n' +
- "\n" +
- "This is a multi-part message in MIME format.\n" +
- "--------------080806020206040800000503\n" +
- "Content-Type: text/plain; charset=ISO-8859-1; format=flowed\n" +
- "Content-Transfer-Encoding: 7bit\n" +
- "\n" +
- msgbodyB +
- "\n" +
- "\n" +
- "--------------080806020206040800000503\n" +
- "Content-Type: message/rfc822;\n" +
- ' name="mail client suggestions.eml"\n' +
- "Content-Transfer-Encoding: 7bit\n" +
- "Content-Disposition: attachment;\n" +
- ' filename="mail client suggestions.eml"\n' +
- "\n" +
- "Return-Path: <example@invalid>\n" +
- "Received: from xxx (smtpu [10.0.0.51])\n" +
- " by storage (Cyrus v2.3.7-Invoca-RPM-2.3.7-1.1) with LMTPA;\n" +
- " Mon, 16 Apr 2012 22:54:36 +0300\n" +
- "Message-ID: <4F8C78F5.4000704@invalid>\n" +
- "Date: Mon, 16 Apr 2012 22:54:29 +0300\n" +
- "From: Mr Example <example@invalid>\n" +
- "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120331 Thunderbird/14.0a1\n" +
- "MIME-Version: 1.0\n" +
- "To: example@invalid\n" +
- "Subject: mail client suggestions\n" +
- "Content-Type: text/plain; charset=ISO-8859-1; format=flowed\n" +
- "Content-Transfer-Encoding: 7bit\n" +
- "\n" +
- msgbodyA +
- "\n" +
- "\n" +
- "--------------080806020206040800000503--\n";
-
- folder.QueryInterface(Ci.nsIMsgLocalMailFolder);
- folder.addMessage(source);
-};
-
-/**
- * Helper to open an attached .eml file, invoke the hotkey and check some
- * properties of the composition content we get.
- */
-function setupWindowAndTest(hotkeyToHit, hotkeyModifiers) {
- be_in_folder(folder);
-
- let msg = select_click_row(0);
- assert_selected_and_displayed(mc, msg);
-
- plan_for_new_window("mail:messageWindow");
- mc.click(mc.eid("attachmentName"));
- let msgWin = wait_for_new_window("mail:messageWindow");
- wait_for_message_display_completion(msgWin, false);
-
- plan_for_new_window("msgcompose");
- msgWin.keypress(null, hotkeyToHit, hotkeyModifiers);
- let compWin = wait_for_compose_window(msgWin);
-
- let bodyText = get_compose_body(compWin).textContent;
- if (bodyText.includes("html")) {
- throw new Error("body text contains raw html; bodyText=" + bodyText);
- }
-
- if (!bodyText.includes(msgbodyA)) {
- throw new Error(
- "body text didn't contain the body text; msgbodyA=" +
- msgbodyB +
- ", bodyText=" +
- bodyText
- );
- }
-
- let subjectText = compWin.e("msgSubject").value;
- if (!subjectText.includes(msgsubject)) {
- throw new Error(
- "subject text didn't contain the original subject; " +
- "msgsubject=" +
- msgsubject +
- ", subjectText=" +
- subjectText
- );
- }
-
- close_compose_window(compWin, false);
- close_window(msgWin);
-}
-
-/**
- * Test that replying to an attached .eml contains the expected texts.
- */
-function test_reply_to_attached_eml() {
- setupWindowAndTest("R", { shiftKey: false, accelKey: true });
-}
-
-/**
- * Test that forwarding an attached .eml contains the expected texts.
- */
-function test_forward_attached_eml() {
- setupWindowAndTest("L", { shiftKey: false, accelKey: true });
-}
deleted file mode 100644
--- a/mail/test/mozmill/composition/test-image-display.js
+++ /dev/null
@@ -1,161 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests that we load and display embedded images in messages.
- */
-
-"use strict";
-
-var os = ChromeUtils.import("chrome://mozmill/content/stdlib/os.jsm");
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-
-var {
- close_compose_window,
- open_compose_with_forward,
- open_compose_with_reply,
-} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
-var {
- assert_false,
- assert_not_equals,
- assert_selected_and_displayed,
- assert_true,
- be_in_folder,
- create_folder,
- mc,
- open_message_from_file,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { close_window } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { IOUtils } = ChromeUtils.import("resource:///modules/IOUtils.js");
-
-var gImageFolder;
-
-function setupModule(module) {
- gImageFolder = create_folder("ImageFolder");
-}
-
-/**
- * Check dimensions of the embedded image and whether it could be loaded.
- */
-function check_image_size(aController, aImage, aSrcStart) {
- assert_not_equals(null, aImage);
- aController.waitFor(() => aImage.complete);
- // There should not be a cid: URL now.
- assert_false(aImage.src.startsWith("cid:"));
- if (aSrcStart) {
- assert_true(aImage.src.startsWith(aSrcStart));
- }
-
- // Check if there are height and width attributes forcing the image to a size.
- let id = aImage.id;
- assert_true(
- aImage.hasAttribute("height"),
- "Image " + id + " is missing a required attribute"
- );
- assert_true(
- aImage.hasAttribute("width"),
- "Image " + id + " is missing a required attribute"
- );
-
- assert_true(
- aImage.height > 0,
- "Image " + id + " is missing a required attribute"
- );
- assert_true(
- aImage.width > 0,
- "Image " + id + " is missing a required attribute"
- );
-
- // If the image couldn't be loaded, the naturalWidth and Height are zero.
- assert_true(
- aImage.naturalHeight > 0,
- "Loaded image " + id + " is of zero size"
- );
- assert_true(
- aImage.naturalWidth > 0,
- "Loaded image " + id + " is of zero size"
- );
-}
-
-/**
- * Bug 1352701 and bug 1360443
- * Test that showing an image with cid: URL in a HTML message from file will work.
- */
-function test_cid_image_load() {
- let file = os.getFileForPath(
- os.abspath("./content-utf8-rel-only.eml", os.getFileForPath(__file__))
- );
-
- // Make sure there is a cid: referenced image in the message.
- let msgSource = IOUtils.loadFileToString(file);
- assert_true(msgSource.includes('<img src="cid:'));
-
- // Our image should be in the loaded eml document.
- let msgc = open_message_from_file(file);
- let messageDoc = msgc.e("messagepane").contentDocument;
- let image = messageDoc.getElementById("cidImage");
- check_image_size(msgc, image, "mailbox://");
- image = messageDoc.getElementById("cidImageOrigin");
- check_image_size(msgc, image, "mailbox://");
-
- // Copy the message to a folder.
- let documentChild = messageDoc.firstElementChild;
- msgc.rightClick(new elib.Elem(documentChild));
- msgc.click_menus_in_sequence(msgc.e("mailContext"), [
- { id: "mailContext-copyMenu" },
- { label: "Local Folders" },
- { label: gImageFolder.prettyName },
- ]);
- close_window(msgc);
-}
-
-/**
- * Bug 1352701 and bug 1360443
- * Test that showing an image with cid: URL in a HTML message in a folder with work.
- */
-function test_cid_image_view() {
- // Preview the message in the folder.
- be_in_folder(gImageFolder);
- let msg = select_click_row(0);
- assert_selected_and_displayed(mc, msg);
-
- // Check image in the preview.
- let messageDoc = mc.e("messagepane").contentDocument;
- let image = messageDoc.getElementById("cidImage");
- check_image_size(mc, image, gImageFolder.server.localStoreType + "://");
- image = messageDoc.getElementById("cidImageOrigin");
- check_image_size(mc, image, gImageFolder.server.localStoreType + "://");
-}
-
-/**
- * Bug 1352701 and bug 1360443
- * Test that showing an image with cid: URL in a HTML message will work
- * in a composition.
- */
-function test_cid_image_compose() {
- // Our image should also be in composition when the message is forwarded/replied.
- for (let msgOperation of [
- open_compose_with_forward,
- open_compose_with_reply,
- ]) {
- let cwc = msgOperation();
- let image = cwc
- .e("content-frame")
- .contentDocument.getElementById("cidImage");
- check_image_size(cwc, image, "data:");
- image = cwc
- .e("content-frame")
- .contentDocument.getElementById("cidImageOrigin");
- check_image_size(cwc, image, "data:");
- close_compose_window(cwc);
- }
-}
deleted file mode 100644
--- a/mail/test/mozmill/composition/test-image-insertion-dialog.js
+++ /dev/null
@@ -1,134 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests the image insertion dialog functionality.
- */
-
-"use strict";
-
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-
-var { close_compose_window, open_compose_new_mail } = ChromeUtils.import(
- "resource://testing-common/mozmill/ComposeHelpers.jsm"
-);
-var { assert_true } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { input_value } = ChromeUtils.import(
- "resource://testing-common/mozmill/KeyboardHelpers.jsm"
-);
-var wh = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-function test_image_insertion_dialog_persist() {
- let cwc = open_compose_new_mail();
-
- // First focus on the editor element
- cwc.e("content-frame").focus();
-
- // Now open the image window
- wh.plan_for_modal_dialog("Mail:image", function insert_image(mwc) {
- // Insert the url of the image.
- let srcloc = mwc.window.document.getElementById("srcInput");
- srcloc.focus();
-
- input_value(mwc, "whateverItDoesntMatterAnyway.png");
- mwc.sleep(0);
-
- // Don't add alternate text
- mwc.click(mwc.eid("noAltTextRadio"));
-
- mwc.window.document.documentElement.querySelector("dialog").acceptDialog();
- });
- cwc.click(cwc.eid("insertImage"));
- wh.wait_for_modal_dialog();
- wh.wait_for_window_close();
-
- // Check that the radio option persists
- wh.plan_for_modal_dialog("Mail:image", function insert_image(mwc) {
- assert_true(
- mwc.window.document.getElementById("noAltTextRadio").selected,
- "We should persist the previously selected value"
- );
- // We change to "use alt text"
- mwc.click(mwc.eid("altTextRadio"));
- mwc.window.document.documentElement.querySelector("dialog").cancelDialog();
- });
- cwc.click(cwc.eid("insertImage"));
- wh.wait_for_modal_dialog();
- wh.wait_for_window_close();
-
- // Check that the radio option still persists (be really sure)
- wh.plan_for_modal_dialog("Mail:image", function insert_image(mwc) {
- assert_true(
- mwc.window.document.getElementById("altTextRadio").selected,
- "We should persist the previously selected value"
- );
- // Accept the dialog
- mwc.window.document.documentElement.querySelector("dialog").cancelDialog();
- });
- cwc.click(cwc.eid("insertImage"));
- wh.wait_for_modal_dialog();
- wh.wait_for_window_close();
- cwc.sleep(500);
-
- // Get the inserted image, double-click it, make sure we switch to "no alt
- // text", despite the persisted value being "use alt text"
- let img = cwc.e("content-frame").contentDocument.querySelector("img");
- wh.plan_for_modal_dialog("Mail:image", function insert_image(mwc) {
- assert_true(
- mwc.window.document.getElementById("noAltTextRadio").selected,
- "We shouldn't use the persisted value because the insert image has no alt text"
- );
- mwc.window.document.documentElement.querySelector("dialog").cancelDialog();
- });
- cwc.doubleClick(new elib.Elem(img));
- wh.wait_for_modal_dialog();
- wh.wait_for_window_close();
- // It's not clear why we have to wait here to avoid test failures,
- // see bug 1246094.
- cwc.sleep(500);
-
- // Now use some alt text for the edit image dialog
- wh.plan_for_modal_dialog("Mail:image", function insert_image(mwc) {
- assert_true(
- mwc.window.document.getElementById("noAltTextRadio").selected,
- "That value should persist still..."
- );
- mwc.click(mwc.eid("altTextRadio"));
-
- let srcloc = mwc.window.document.getElementById("altTextInput");
- srcloc.focus();
- input_value(mwc, "some alt text");
- mwc.sleep(0);
- // Accept the dialog
- mwc.window.document.documentElement.querySelector("dialog").acceptDialog();
- });
- cwc.doubleClick(new elib.Elem(img));
- wh.wait_for_modal_dialog();
- wh.wait_for_window_close();
- // It's not clear why we have to wait here to avoid test failures,
- // see bug 1246094.
- cwc.sleep(500);
-
- // Make sure next time we edit it, we still have "use alt text" selected.
- img = cwc.e("content-frame").contentDocument.querySelector("img");
- wh.plan_for_modal_dialog("Mail:image", function insert_image(mwc) {
- assert_true(
- mwc.window.document.getElementById("altTextRadio").selected,
- "We edited the image to make it have alt text, we should keep it selected"
- );
- // Accept the dialog
- mwc.window.document.documentElement.querySelector("dialog").cancelDialog();
- });
- cwc.doubleClick(new elib.Elem(img));
- wh.wait_for_modal_dialog();
- wh.wait_for_window_close();
-
- close_compose_window(cwc);
-}
deleted file mode 100644
--- a/mail/test/mozmill/composition/test-multipart-related.js
+++ /dev/null
@@ -1,139 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests that multipart/related messages are handled properly.
- */
-
-"use strict";
-
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-var os = ChromeUtils.import("chrome://mozmill/content/stdlib/os.jsm");
-var utils = ChromeUtils.import("chrome://mozmill/content/modules/utils.jsm");
-
-var { close_compose_window, open_compose_new_mail } = ChromeUtils.import(
- "resource://testing-common/mozmill/ComposeHelpers.jsm"
-);
-var {
- assert_equals,
- be_in_folder,
- get_special_folder,
- mc,
- press_delete,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var {
- plan_for_modal_dialog,
- wait_for_modal_dialog,
- wait_for_window_close,
-} = ChromeUtils.import("resource://testing-common/mozmill/WindowHelpers.jsm");
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-var { MimeParser } = ChromeUtils.import("resource:///modules/mimeParser.jsm");
-
-var gDrafts;
-
-function setupModule(module) {
- gDrafts = get_special_folder(Ci.nsMsgFolderFlags.Drafts, true);
-}
-
-/**
- * Helper to get the full message content.
- *
- * @param aMsgHdr: nsIMsgDBHdr object whose text body will be read
- * @return {Map(partnum -> message headers), Map(partnum -> message text)}
- */
-function getMsgHeaders(aMsgHdr) {
- let msgFolder = aMsgHdr.folder;
- let msgUri = msgFolder.getUriForMsg(aMsgHdr);
-
- let messenger = Cc["@mozilla.org/messenger;1"].createInstance(
- Ci.nsIMessenger
- );
- let handler = {
- _done: false,
- _data: new Map(),
- _text: new Map(),
- endMessage() {
- this._done = true;
- },
- deliverPartData(num, text) {
- this._text.set(num, this._text.get(num) + text);
- },
- startPart(num, headers) {
- this._data.set(num, headers);
- this._text.set(num, "");
- },
- };
- let streamListener = MimeParser.makeStreamListenerParser(handler, {
- strformat: "unicode",
- });
- messenger
- .messageServiceFromURI(msgUri)
- .streamMessage(msgUri, streamListener, null, null, false, "", false);
- utils.waitFor(() => handler._done);
- return { headers: handler._data, text: handler._text };
-}
-
-/**
- */
-function test_basic_multipart_related() {
- let compWin = open_compose_new_mail();
- compWin.type(null, "someone@example.com");
- compWin.type(compWin.eid("msgSubject"), "multipart/related");
- compWin.type(compWin.eid("content-frame"), "Here is a prologue.\n");
-
- const fname = "./tb-logo.png";
- let file = os.getFileForPath(os.abspath(fname, os.getFileForPath(__file__)));
- let fileHandler = Services.io
- .getProtocolHandler("file")
- .QueryInterface(Ci.nsIFileProtocolHandler);
- let fileURL = fileHandler.getURLSpecFromFile(file);
-
- // Add a simple image to our dialog
- plan_for_modal_dialog("Mail:image", function(dialog) {
- // Insert the url of the image.
- dialog.type(null, fileURL);
- dialog.type(dialog.eid("altTextInput"), "Alt text");
- dialog.sleep(0);
-
- // Accept the dialog
- dialog.window.document.querySelector("dialog").acceptDialog();
- });
- compWin.click(compWin.eid("insertImage"));
- wait_for_modal_dialog();
- wait_for_window_close();
-
- // Ctrl+S = save as draft.
- compWin.keypress(null, "s", { shiftKey: false, accelKey: true });
- close_compose_window(compWin);
-
- // Make sure that the headers are right on this one.
- be_in_folder(gDrafts);
- let draftMsg = select_click_row(0);
- let { headers, text } = getMsgHeaders(draftMsg, true);
- assert_equals(headers.get("").contentType.type, "multipart/related");
- assert_equals(headers.get("1").contentType.type, "text/html");
- assert_equals(headers.get("2").contentType.type, "image/png");
- assert_equals(headers.get("2").get("Content-Transfer-Encoding"), "base64");
- assert_equals(
- headers.get("2").getRawHeader("Content-Disposition")[0],
- 'inline; filename="tb-logo.png"'
- );
- let cid = headers
- .get("2")
- .getRawHeader("Content-ID")[0]
- .slice(1, -1);
- if (!text.get("1").includes('src="cid:' + cid + '"')) {
- throw new Error("Expected HTML to refer to cid " + cid);
- }
- press_delete(mc); // Delete message
-}
deleted file mode 100644
--- a/mail/test/mozmill/composition/test-newmsg-compose-identity.js
+++ /dev/null
@@ -1,276 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests that compose new message chooses the correct initial identity when
- * called from the context of an open composer.
- */
-
-"use strict";
-
-var {
- close_compose_window,
- open_compose_new_mail,
- wait_for_compose_window,
-} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
-var {
- assert_equals,
- be_in_folder,
- get_special_folder,
- mc,
- press_delete,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { plan_for_new_window } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var gInbox;
-var gDrafts;
-var account;
-
-var identityKey1;
-var identity1Email = "x@example.invalid";
-var identityKey2;
-var identity2Email = "y@example.invalid";
-var identity2Name = "User Y";
-var identity2From = identity2Name + " <" + identity2Email + ">";
-var identityKey3;
-var identity3Email = "z@example.invalid";
-var identity3Name = "User Z";
-var identity3Label = "Label Z";
-var identityKey4;
-
-function setupModule(module) {
- // Now set up an account with some identities.
- let acctMgr = MailServices.accounts;
- account = acctMgr.createAccount();
- account.incomingServer = acctMgr.createIncomingServer(
- "nobody",
- "New Msg Compose Identity Testing",
- "pop3"
- );
-
- let identity1 = acctMgr.createIdentity();
- identity1.email = identity1Email;
- account.addIdentity(identity1);
- identityKey1 = identity1.key;
-
- let identity2 = acctMgr.createIdentity();
- identity2.email = identity2Email;
- identity2.fullName = identity2Name;
- account.addIdentity(identity2);
- identityKey2 = identity2.key;
-
- let identity3 = acctMgr.createIdentity();
- identity3.email = identity3Email;
- identity3.fullName = identity3Name;
- identity3.label = identity3Label;
- account.addIdentity(identity3);
- identityKey3 = identity3.key;
-
- // Identity with no data.
- let identity4 = acctMgr.createIdentity();
- account.addIdentity(identity4);
- identityKey4 = identity4.key;
-
- gInbox = account.incomingServer.rootFolder.getFolderWithFlags(
- Ci.nsMsgFolderFlags.Inbox
- );
- gDrafts = get_special_folder(Ci.nsMsgFolderFlags.Drafts, true);
-}
-
-/**
- * Helper to check that a suitable From identity was set up in the given
- * composer window.
- *
- * @param cwc Compose window controller.
- * @param aIdentityKey The key of the expected identity.
- * @param aIdentityAlias The displayed label of the expected identity.
- * @param aIdentityValue The value of the expected identity
- * (the sender address to be sent out).
- */
-function checkCompIdentity(cwc, aIdentityKey, aIdentityAlias, aIdentityValue) {
- let identityList = cwc.e("msgIdentity");
-
- assert_equals(
- cwc.window.getCurrentIdentityKey(),
- aIdentityKey,
- "The From identity is not correctly selected"
- );
-
- if (aIdentityAlias) {
- assert_equals(
- identityList.label,
- aIdentityAlias,
- "The From address does not have the correct label"
- );
- }
-
- if (aIdentityValue) {
- assert_equals(
- identityList.value,
- aIdentityValue,
- "The From address does not have the correct value"
- );
- }
-}
-
-/**
- * Test that starting a new message from an open compose window gets the
- * expected initial identity.
- */
-function test_compose_from_composer() {
- be_in_folder(gInbox);
-
- let mainCompWin = open_compose_new_mail();
- checkCompIdentity(mainCompWin, account.defaultIdentity.key);
-
- // Compose a new message from the compose window.
- plan_for_new_window("msgcompose");
- mainCompWin.keypress(null, "n", { shiftKey: false, accelKey: true });
- let newCompWin = wait_for_compose_window();
- checkCompIdentity(newCompWin, account.defaultIdentity.key);
- close_compose_window(newCompWin);
-
- // Switch to identity2 in the main compose window, new compose windows
- // starting from here should use the same identity as its "parent".
- mainCompWin.click(mainCompWin.eid("msgIdentity"));
- mainCompWin.click_menus_in_sequence(mainCompWin.e("msgIdentityPopup"), [
- { identitykey: identityKey2 },
- ]);
- checkCompIdentity(mainCompWin, identityKey2);
-
- // Compose a second new message from the compose window.
- plan_for_new_window("msgcompose");
- mainCompWin.keypress(null, "n", { shiftKey: false, accelKey: true });
- let newCompWin2 = wait_for_compose_window();
- checkCompIdentity(newCompWin2, identityKey2);
-
- close_compose_window(newCompWin2);
-
- close_compose_window(mainCompWin);
-}
-
-/**
- * Bug 87987
- * Test editing the identity email/name for the current composition.
- */
-function test_editing_identity() {
- Services.prefs.setBoolPref("mail.compose.warned_about_customize_from", true);
- be_in_folder(gInbox);
-
- let compWin = open_compose_new_mail();
- checkCompIdentity(compWin, account.defaultIdentity.key, identity1Email);
-
- // Input custom identity data into the From field.
- let customName = "custom";
- let customEmail = "custom@edited.invalid";
- let identityCustom = customName + " <" + customEmail + ">";
-
- compWin.click(compWin.eid("msgIdentity"));
- compWin.click_menus_in_sequence(compWin.e("msgIdentityPopup"), [
- { command: "cmd_customizeFromAddress" },
- ]);
- compWin.waitFor(() => compWin.e("msgIdentity").editable);
-
- compWin.type(compWin.eid("msgIdentityPopup"), identityCustom);
- checkCompIdentity(
- compWin,
- account.defaultIdentity.key,
- identityCustom,
- identityCustom
- );
- close_compose_window(compWin);
-
- /* Temporarily disabled due to intermittent failure, bug 1237565.
- TODO: To be reeabled in bug 1238264.
- // Save message with this changed identity.
- compWin.window.SaveAsDraft();
-
- // Switch to another identity to see if editable field still obeys predefined
- // identity values.
- compWin.click_menus_in_sequence(compWin.e("msgIdentityPopup"),
- [ { identitykey: identityKey2 } ]);
- checkCompIdentity(compWin, identityKey2, identity2From, identity2From);
-
- // This should not save the identity2 to the draft message.
- close_compose_window(compWin);
-
- be_in_folder(gDrafts);
- let curMessage = select_click_row(0);
- assert_equals(curMessage.author, identityCustom);
- // Remove the saved draft.
- press_delete(mc);
- */
- Services.prefs.setBoolPref("mail.compose.warned_about_customize_from", false);
-}
-
-/**
- * Bug 318495
- * Test how an identity displays and behaves in the compose window.
- */
-function test_display_of_identities() {
- be_in_folder(gInbox);
-
- let cwc = open_compose_new_mail();
- checkCompIdentity(cwc, account.defaultIdentity.key, identity1Email);
-
- cwc.click(cwc.eid("msgIdentity"));
- cwc.click_menus_in_sequence(cwc.e("msgIdentityPopup"), [
- { identitykey: identityKey2 },
- ]);
- checkCompIdentity(cwc, identityKey2, identity2From, identity2From);
-
- cwc.click(cwc.eid("msgIdentity"));
- cwc.click_menus_in_sequence(cwc.e("msgIdentityPopup"), [
- { identitykey: identityKey4 },
- ]);
- checkCompIdentity(
- cwc,
- identityKey4,
- "[nsIMsgIdentity: " + identityKey4 + "]"
- );
-
- cwc.click(cwc.eid("msgIdentity"));
- cwc.click_menus_in_sequence(cwc.e("msgIdentityPopup"), [
- { identitykey: identityKey3 },
- ]);
- let identity3From = identity3Name + " <" + identity3Email + ">";
- checkCompIdentity(
- cwc,
- identityKey3,
- identity3From + " (" + identity3Label + ")",
- identity3From
- );
-
- // Bug 1152045, check that the email address from the selected identity
- // is properly used for the From field in the created message.
- cwc.window.SaveAsDraft();
- close_compose_window(cwc);
-
- be_in_folder(gDrafts);
- let curMessage = select_click_row(0);
- assert_equals(curMessage.author, identity3From);
- // Remove the saved draft.
- press_delete(mc);
-}
-
-function teardownModule(module) {
- account.removeIdentity(MailServices.accounts.getIdentity(identityKey1));
- account.removeIdentity(MailServices.accounts.getIdentity(identityKey2));
- account.removeIdentity(MailServices.accounts.getIdentity(identityKey3));
-
- // The last identity of an account can't be removed so clear all its prefs
- // which effectively destroys it.
- MailServices.accounts.getIdentity(identityKey4).clearAllValues();
- MailServices.accounts.removeAccount(account);
-}
deleted file mode 100644
--- a/mail/test/mozmill/composition/test-reply-addresses.js
+++ /dev/null
@@ -1,1111 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests that we get correct adressees for different type of replies:
- * reply to sender, reply to all, reply to list, mail-followup-tp,
- * mail-reply-to, and reply to self.
- */
-
-"use strict";
-
-var {
- close_compose_window,
- open_compose_with_reply,
- open_compose_with_reply_to_all,
- open_compose_with_reply_to_list,
-} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
-var {
- add_message_to_folder,
- assert_equals,
- assert_selected_and_displayed,
- be_in_folder,
- create_message,
- mc,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var folder;
-var i = 0;
-
-var myEmail = "me@example.com";
-var myEmail2 = "otherme@example.com";
-
-var identity;
-var identity2;
-
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-function setupModule(module) {
- // Now set up an account with some identities.
- let acctMgr = MailServices.accounts;
- let account = acctMgr.createAccount();
- account.incomingServer = acctMgr.createIncomingServer(
- "nobody",
- "Reply Addresses Testing",
- "pop3"
- );
-
- folder = account.incomingServer.rootFolder
- .QueryInterface(Ci.nsIMsgLocalMailFolder)
- .createLocalSubfolder("Msgs4Reply");
-
- identity = acctMgr.createIdentity();
- identity.email = myEmail;
- account.addIdentity(identity);
-
- identity2 = acctMgr.createIdentity();
- identity2.email = myEmail2;
- account.addIdentity(identity2);
-
- // Let's add messages to the folder later as we go, it's hard to read
- // out of context what the expected results should be.
-}
-
-/**
- * Helper to open a reply, check the fields are as expected, and close the
- * reply window.
- * @param aReplyFunction which reply function to call
- * @param aExpectedFields the fields expected
- */
-function checkReply(aReplyFunction, aExpectedFields) {
- let rwc = aReplyFunction();
- checkToAddresses(rwc, aExpectedFields);
- close_compose_window(rwc);
-}
-
-/**
- * Helper to check that the reply window has the expected address fields.
- */
-function checkToAddresses(replyWinController, expectedFields) {
- let rows = replyWinController.window.document.querySelectorAll(
- "#recipientsContainer .address-row:not(.hidden)"
- );
-
- let obtainedFields = [];
- for (let row of rows) {
- let addrTextbox = row.querySelector(
- `input[is="autocomplete-input"][recipienttype]`
- );
-
- let addresses = [];
- for (let pill of row.querySelectorAll("mail-address-pill")) {
- addresses.push(pill.fullAddress);
- }
-
- obtainedFields[addrTextbox.getAttribute("recipienttype")] = addresses;
- }
-
- // Check what we expect is there.
- for (let type in expectedFields) {
- let expected = expectedFields[type];
- let obtained = obtainedFields[type];
-
- for (let i = 0; i < expected.length; i++) {
- if (!obtained || !obtained.includes(expected[i])) {
- throw new Error(
- expected[i] +
- " is not in " +
- type +
- " fields; " +
- "obtained=" +
- obtained
- );
- }
- }
- assert_equals(
- obtained.length,
- expected.length,
- "Unexpected number of fields obtained for type=" +
- type +
- "; obtained=" +
- obtained +
- "; expected=" +
- expected
- );
- }
-
- // Check there's no "extra" fields either.
- for (let type in obtainedFields) {
- let expected = expectedFields[type];
- let obtained = obtainedFields[type];
- if (!expected) {
- throw new Error(
- "Didn't expect a field for type=" + type + "; obtained=" + obtained
- );
- }
- }
-}
-
-/**
- * Helper to set an auto-Cc list for an identity.
- */
-function useAutoCc(aIdentity, aCcList) {
- aIdentity.doCc = true;
- aIdentity.doCcList = aCcList;
-}
-
-/**
- * Helper to stop using auto-Cc for an identity.
- */
-function stopUsingAutoCc(aIdentity) {
- aIdentity.doCc = false;
- aIdentity.doCcList = "";
-}
-
-/**
- * Helper to ensure autoCc is turned off.
- */
-function ensureNoAutoCc(aIdentity) {
- aIdentity.doCc = false;
-}
-
-/**
- * Helper to set an auto-bcc list for an identity.
- */
-function useAutoBcc(aIdentity, aBccList) {
- aIdentity.doBcc = true;
- aIdentity.doBccList = aBccList;
-}
-
-/**
- * Helper to stop using auto-bcc for an identity.
- */
-function stopUsingAutoBcc(aIdentity) {
- aIdentity.doBcc = false;
- aIdentity.doBccList = "";
-}
-
-/**
- * Helper to ensure auto-bcc is turned off.
- */
-function ensureNoAutoBcc(aIdentity) {
- aIdentity.doBcc = false;
-}
-
-/**
- * Tests that for a list post with munged Reply-To:
- * - reply: goes to From
- * - reply all: includes From + the usual thing
- * - reply list: goes to the list
- */
-function testReplyToMungedReplyToList() {
- let msg0 = create_message({
- from: "Tester <test@example.com>",
- to: "munged.list@example.com, someone.else@example.com",
- subject: "testReplyToMungedReplyToList",
- clobberHeaders: {
- "Reply-To": "Munged List <munged.list@example.com>",
- "List-Post": "<mailto:munged.list@example.com>",
- },
- });
- add_message_to_folder(folder, msg0);
-
- be_in_folder(folder);
- let msg = select_click_row(i++);
- assert_selected_and_displayed(mc, msg);
-
- ensureNoAutoCc(identity);
-
- checkReply(open_compose_with_reply, {
- addr_to: ["Tester <test@example.com>"],
- });
-
- checkReply(open_compose_with_reply_to_all, {
- addr_to: [
- "Munged List <munged.list@example.com>",
- "someone.else@example.com",
- "Tester <test@example.com>",
- ],
- });
-
- checkReply(open_compose_with_reply_to_list, {
- addr_to: ["munged.list@example.com"],
- });
-}
-
-/**
- * Tests that addresses get set properly when doing a normal reply.
- */
-function testToCcReply() {
- let msg0 = create_message({
- from: "Homer <homer@example.com>",
- to: "Mr Burns <mrburns@example.com>, workers@example.com, " + myEmail,
- cc: "Lisa <lisa@example.com>",
- subject: "testToCcReply - normal mail with to and cc (me in To)",
- });
- add_message_to_folder(folder, msg0);
-
- be_in_folder(folder);
- let msg = select_click_row(i++);
- assert_selected_and_displayed(mc, msg);
-
- ensureNoAutoCc(identity);
- checkReply(
- open_compose_with_reply,
- // To: From
- { addr_to: ["Homer <homer@example.com>"] }
- );
-
- useAutoCc(identity, myEmail + ", smithers@example.com");
- checkReply(
- open_compose_with_reply,
- // To: From
- // Cc: identity Cc list, including self.
- {
- addr_to: ["Homer <homer@example.com>"],
- addr_cc: [myEmail, "smithers@example.com"],
- }
- );
- stopUsingAutoCc(identity);
-}
-
-/**
- * Tests that addresses get set properly when doing a normal reply to all.
- */
-function testToCcReplyAll() {
- let msg0 = create_message({
- from: "Homer <homer@example.com>",
- to: "Mr Burns <mrburns@example.com>, workers@example.com, " + myEmail,
- cc: "Lisa <lisa@example.com>",
- subject: "testToCcReplyAll - normal mail with to and cc (me in To)",
- });
- add_message_to_folder(folder, msg0);
-
- be_in_folder(folder);
- let msg = select_click_row(i++);
- assert_selected_and_displayed(mc, msg);
-
- ensureNoAutoCc(identity);
- checkReply(
- open_compose_with_reply_to_all,
- // To: From + Tos without me.
- // Cc: original Ccs
- {
- addr_to: [
- "Homer <homer@example.com>",
- "Mr Burns <mrburns@example.com>",
- "workers@example.com",
- ],
- addr_cc: ["Lisa <lisa@example.com>"],
- }
- );
-
- useAutoCc(identity, myEmail + ", smithers@example.com");
- checkReply(
- open_compose_with_reply_to_all,
- // To: From + Tos without me.
- // Cc: original Ccs + auto-Ccs
- {
- addr_to: [
- "Homer <homer@example.com>",
- "Mr Burns <mrburns@example.com>",
- "workers@example.com",
- ],
- addr_cc: ["Lisa <lisa@example.com>", myEmail, "smithers@example.com"],
- }
- );
- stopUsingAutoCc(identity);
-}
-
-/**
- * Tests that that addresses get set properly when doing a normal reply to all
- * where when recipients aren't all ascii.
- */
-function testToCcReplyAllInternational() {
- let msg0 = create_message({
- from:
- "Hideaki / =?iso-2022-jp?B?GyRCNUhGIzFRTEAbKEI=?= <hideaki@example.com>",
- to:
- "Mr Burns <mrburns@example.com>, =?UTF-8?B?w4VrZQ==?= <ake@example.com>, " +
- "=?KOI8-R?Q?=E9=D7=C1=CE?= <ivan@example.com>, " +
- myEmail,
- cc: "=?Big5?B?pP2oca1e?= <xiuying@example.com>",
- subject:
- "testToCcReplyAllInternational - non-ascii people mail with to and cc (me in To)",
- clobberHeaders: { "Content-Transfer-Encoding": "quoted-printable" },
- // Content-Transfer-Encoding ^^^ should be set from the body encoding below,
- // but that doesn't seem to work. (No Content-Transfer-Encoding header is
- // generated).
- body: {
- charset: "windows-1251",
- encoding: "quoted-printable",
- body: "=CF=F0=E8=E2=E5=F2 =E8=E7 =CC=EE=F1=EA=E2=FB",
- },
- });
- add_message_to_folder(folder, msg0);
-
- be_in_folder(folder);
- let msg = select_click_row(i++);
- assert_selected_and_displayed(mc, msg);
-
- ensureNoAutoCc(identity);
- checkReply(
- open_compose_with_reply_to_all,
- // To: From + Tos without me.
- // Cc: original Ccs
- {
- addr_to: [
- "Hideaki / å‰è—¤è‹±æ˜Ž <hideaki@example.com>",
- "Mr Burns <mrburns@example.com>",
- "Ã…ke <ake@example.com>",
- "Иван <ivan@example.com>",
- ],
- addr_cc: ["王秀英 <xiuying@example.com>"],
- }
- );
-
- useAutoCc(identity, "Ã…sa <asa@example.com>");
- checkReply(
- open_compose_with_reply_to_all,
- // To: From + Tos without me.
- // Cc: original Ccs + auto-Ccs
- {
- addr_to: [
- "Hideaki / å‰è—¤è‹±æ˜Ž <hideaki@example.com>",
- "Mr Burns <mrburns@example.com>",
- "Ã…ke <ake@example.com>",
- "Иван <ivan@example.com>",
- ],
- addr_cc: ["王秀英 <xiuying@example.com>", "Åsa <asa@example.com>"],
- }
- );
- stopUsingAutoCc(identity);
-}
-
-/**
- * Tests that that addresses get set properly when doing a reply to a mail with
- * reply-to set.
- */
-function testToCcReplyWhenReplyToSet() {
- let msg0 = create_message({
- from: "Homer <homer@example.com>",
- to: "workers@example.com",
- cc: "Lisa <lisa@example.com>, " + myEmail,
- subject:
- "testToCcReplyWhenReplyToSet - to/cc mail with reply-to set (me in Cc)",
- clobberHeaders: {
- "Reply-To": "marge@example.com",
- },
- });
- add_message_to_folder(folder, msg0);
-
- be_in_folder(folder);
- let msg = select_click_row(i++);
- assert_selected_and_displayed(mc, msg);
-
- ensureNoAutoCc(identity);
- checkReply(
- open_compose_with_reply,
- // To: reply-to
- { addr_to: ["marge@example.com"] }
- );
-
- useAutoCc(identity, myEmail + ", smithers@example.com");
- checkReply(
- open_compose_with_reply,
- // To: reply-to
- // Cc: auto-Ccs
- {
- addr_to: ["marge@example.com"],
- addr_cc: [myEmail, "smithers@example.com"],
- }
- );
- stopUsingAutoCc(identity);
-}
-
-/**
- * Tests that addresses get set properly when doing a reply to all for a mail
- * w/ Reply-To.
- */
-function testToCcReplyAllWhenReplyToSet() {
- let msg0 = create_message({
- from: "Homer <homer@example.com>",
- to: "workers@example.com",
- cc: "Lisa <lisa@example.com>, " + myEmail,
- subject:
- "testToCcReplyAllWhenReplyToSet - to/cc mail with reply-to set (me in Cc)",
- clobberHeaders: {
- "Reply-To": "marge@example.com",
- },
- });
- add_message_to_folder(folder, msg0);
-
- be_in_folder(folder);
- let msg = select_click_row(i++);
- assert_selected_and_displayed(mc, msg);
-
- ensureNoAutoCc(identity);
- checkReply(
- open_compose_with_reply_to_all,
- // To: Reply-To + Tos
- // Cc: original Ccs without me.
- {
- addr_to: ["marge@example.com", "workers@example.com"],
- addr_cc: ["Lisa <lisa@example.com>"],
- }
- );
-
- useAutoCc(identity, myEmail + ", smithers@example.com");
- checkReply(
- open_compose_with_reply_to_all,
- // To: Reply-To + Tos
- // Cc: original Ccs + auto-Ccs (which includes me!)
- {
- addr_to: ["marge@example.com", "workers@example.com"],
- addr_cc: ["Lisa <lisa@example.com>", myEmail, "smithers@example.com"],
- }
- );
- stopUsingAutoCc(identity);
-}
-
-/**
- * Tests that addresses get set properly when doing a reply to list.
- */
-function testReplyToList() {
- let msg0 = create_message({
- from: "Homer <homer@example.com>",
- to: "workers-list@example.com",
- cc: "Lisa <lisa@example.com>, " + myEmail,
- subject: "testReplyToList - mailing list message (me in Cc)",
- clobberHeaders: {
- "List-Post": "<mailto:workers-list@example.com>",
- },
- });
- add_message_to_folder(folder, msg0);
-
- be_in_folder(folder);
- let msg = select_click_row(i++);
- assert_selected_and_displayed(mc, msg);
-
- ensureNoAutoCc(identity);
- checkReply(
- open_compose_with_reply_to_list,
- // To: the list
- { addr_to: ["workers-list@example.com"] }
- );
-
- useAutoCc(identity, myEmail + ", smithers@example.com");
- checkReply(
- open_compose_with_reply_to_list,
- // To: the list
- // Cc: auto-Ccs
- {
- addr_to: ["workers-list@example.com"],
- addr_cc: [myEmail, "smithers@example.com"],
- }
- );
- stopUsingAutoCc(identity);
-}
-
-/**
- * Tests that addresses get set properly when doing a reply to sender for a
- * list post.
- */
-function testReplySenderForListPost() {
- let msg0 = create_message({
- from: "Homer <homer@example.com>",
- to: "workers-list@example.com",
- cc: "Lisa <lisa@example.com>, " + myEmail,
- subject: "testReplySenderForListPost - mailing list message (me in Cc)",
- clobberHeaders: {
- "List-Post": "<mailto:workers-list@example.com>",
- },
- });
- add_message_to_folder(folder, msg0);
-
- be_in_folder(folder);
- let msg = select_click_row(i++);
- assert_selected_and_displayed(mc, msg);
-
- ensureNoAutoCc(identity);
- checkReply(
- open_compose_with_reply,
- // To: From
- { addr_to: ["Homer <homer@example.com>"] }
- );
-
- useAutoCc(identity, myEmail + ", smithers@example.com");
- checkReply(
- open_compose_with_reply,
- // To: From
- // Cc: auto-Ccs
- {
- addr_to: ["Homer <homer@example.com>"],
- addr_cc: [myEmail, "smithers@example.com"],
- }
- );
- stopUsingAutoCc(identity);
-}
-
-/**
- * Tests that addresses get set properly when doing a reply all to a list post.
- */
-function testReplyToAllForListPost() {
- let msg0 = create_message({
- from: "Homer <homer@example.com>",
- to: "workers-list@example.com",
- cc: "Lisa <lisa@example.com>, " + myEmail,
- subject: "testReplyToAllForListPost - mailing list message (me in Cc)",
- clobberHeaders: {
- "List-Post": "<mailto:workers-list@example.com>",
- },
- });
- add_message_to_folder(folder, msg0);
-
- be_in_folder(folder);
- let msg = select_click_row(i++);
- assert_selected_and_displayed(mc, msg);
-
- ensureNoAutoCc(identity);
- checkReply(
- open_compose_with_reply_to_all,
- // To: From + original To
- // Cc: original CC without me
- {
- addr_to: ["Homer <homer@example.com>", "workers-list@example.com"],
- addr_cc: ["Lisa <lisa@example.com>"],
- }
- );
-
- useAutoCc(identity, myEmail + ", smithers@example.com");
- checkReply(
- open_compose_with_reply_to_all,
- // To: From + original To
- // Cc: original CC + auto-Ccs (including me!)
- {
- addr_to: ["Homer <homer@example.com>", "workers-list@example.com"],
- addr_cc: ["Lisa <lisa@example.com>", myEmail, "smithers@example.com"],
- }
- );
- stopUsingAutoCc(identity);
-}
-
-/**
- * Tests that addresses get set properly when doing a reply to all for a list
- * post when also reply-to is set.
- */
-function testReplyToListWhenReplyToSet() {
- let msg0 = create_message({
- from: "Homer <homer@example.com>",
- to: "workers-list@example.com, " + myEmail,
- cc: "Lisa <lisa@example.com>",
- subject:
- "testReplyToListWhenReplyToSet - mailing list message w/ cc, reply-to (me in To)",
- clobberHeaders: {
- "Reply-To": "marge@example.com",
- "List-Post": "<mailto:workers-list@example.com>",
- },
- });
- add_message_to_folder(folder, msg0);
-
- be_in_folder(folder);
- let msg = select_click_row(i++);
- assert_selected_and_displayed(mc, msg);
-
- ensureNoAutoCc(identity);
- checkReply(
- open_compose_with_reply_to_all,
- // To: Reply-To, original Tos
- // Cc: original Cc
- {
- addr_to: ["marge@example.com", "workers-list@example.com"],
- addr_cc: ["Lisa <lisa@example.com>"],
- }
- );
-
- useAutoCc(identity, myEmail + ", smithers@example.com");
- checkReply(
- open_compose_with_reply_to_all,
- // To: Reply-To, original Tos
- // Cc: original Cc + auto-Ccs
- {
- addr_to: ["marge@example.com", "workers-list@example.com"],
- addr_cc: ["Lisa <lisa@example.com>", myEmail, "smithers@example.com"],
- }
- );
- stopUsingAutoCc(identity);
-}
-
-/**
- * Test that addresses get set properly for Mail-Reply-To. Mail-Reply-To should
- * be used for reply to author, if present.
- * @see http://cr.yp.to/proto/replyto.html
- */
-function testMailReplyTo() {
- let msg0 = create_message({
- from: "Homer <homer@example.com>",
- to: "workers-list@example.com",
- cc: "Lisa <lisa@example.com>",
- subject: "testMailReplyTo - mail with Mail-Reply-To header",
- clobberHeaders: {
- "Reply-To": "workers-list@example.com", // reply-to munging
- "Mail-Reply-To": "Homer S. <homer@example.com>",
- },
- });
- add_message_to_folder(folder, msg0);
-
- be_in_folder(folder);
- let msg = select_click_row(i++);
- assert_selected_and_displayed(mc, msg);
-
- ensureNoAutoCc(identity);
- checkReply(
- open_compose_with_reply,
- // To: Mail-Reply-To
- { addr_to: ["Homer S. <homer@example.com>"] }
- );
-
- useAutoCc(identity, myEmail + ", smithers@example.com");
- checkReply(
- open_compose_with_reply,
- // To: Mail-Reply-To
- // Cc: auto-Ccs
- {
- addr_to: ["Homer S. <homer@example.com>"],
- addr_cc: [myEmail, "smithers@example.com"],
- }
- );
- stopUsingAutoCc(identity);
-}
-
-/**
- * Test that addresses get set properly Mail-Followup-To. Mail-Followup-To
- * should be the default recipient list for reply-all, if present.
- * @see http://cr.yp.to/proto/replyto.html
- */
-function testMailFollowupTo() {
- let msg0 = create_message({
- from: "Homer <homer@example.com>",
- to: "workers-list@example.com, " + myEmail,
- cc: "Lisa <lisa@example.com>",
- subject: "testMailFollowupTo - mail with Mail-Followup-To header",
- clobberHeaders: {
- // Homer is on the list, and don't want extra copies, so he has
- // set the Mail-Followup-To header so followups go to the list.
- "Mail-Followup-To": "workers-list@example.com",
- },
- });
- add_message_to_folder(folder, msg0);
-
- be_in_folder(folder);
- let msg = select_click_row(i++);
- assert_selected_and_displayed(mc, msg);
-
- ensureNoAutoCc(identity);
- checkReply(
- open_compose_with_reply_to_all,
- // To: Mail-Followup-To
- { addr_to: ["workers-list@example.com"] }
- );
-
- useAutoCc(identity, myEmail + ", smithers@example.com");
- checkReply(
- open_compose_with_reply_to_all,
- // To: Mail-Followup-To
- // Cc: auto-Ccs
- {
- addr_to: ["workers-list@example.com"],
- addr_cc: [myEmail, "smithers@example.com"],
- }
- );
- stopUsingAutoCc(identity);
-}
-
-/**
- * Tests that addresses get set properly for reply to self.
- */
-function testReplyToSelfReply() {
- let msg0 = create_message({
- from: myEmail,
- to: "Bart <bart@example.com>, Maggie <maggie@example.com>",
- cc: "Lisa <lisa@example.com>",
- subject: "testReplyToSelfReply - reply to self",
- clobberHeaders: {
- Bcc: "Moe <moe@example.com>",
- "Reply-To": "Flanders <flanders@example.com>",
- },
- });
- add_message_to_folder(folder, msg0);
-
- be_in_folder(folder);
- let msg = select_click_row(i++);
- assert_selected_and_displayed(mc, msg);
-
- ensureNoAutoCc(identity);
- checkReply(
- open_compose_with_reply,
- // To: original To
- // Reply-To: original Reply-To
- {
- addr_to: ["Bart <bart@example.com>", "Maggie <maggie@example.com>"],
- addr_reply: ["Flanders <flanders@example.com>"],
- }
- );
-
- useAutoCc(identity, myEmail + ", smithers@example.com");
- checkReply(
- open_compose_with_reply,
- // To: original To
- // Cc: auto-Ccs
- // Reply-To: original Reply-To
- {
- addr_to: ["Bart <bart@example.com>", "Maggie <maggie@example.com>"],
- addr_cc: [myEmail, "smithers@example.com"],
- addr_reply: ["Flanders <flanders@example.com>"],
- }
- );
- stopUsingAutoCc(identity);
-}
-
-/**
- * Tests that addresses get set properly for a reply all to self - this should
- * be treated as a followup.
- */
-function testReplyToSelfReplyAll() {
- let msg0 = create_message({
- from: myEmail,
- to: "Bart <bart@example.com>, Maggie <maggie@example.com>",
- cc: "Lisa <lisa@example.com>",
- subject: "testReplyToSelfReplyAll - reply to self",
- clobberHeaders: {
- Bcc: "Moe <moe@example.com>",
- "Reply-To": "Flanders <flanders@example.com>",
- },
- });
- add_message_to_folder(folder, msg0);
-
- be_in_folder(folder);
- let msg = select_click_row(i++);
- assert_selected_and_displayed(mc, msg);
-
- ensureNoAutoCc(identity);
- checkReply(
- open_compose_with_reply_to_all,
- // To: original To
- // Cc: original Cc
- // Bcc: original Bcc
- // Reply-To: original Reply-To
- {
- addr_to: ["Bart <bart@example.com>", "Maggie <maggie@example.com>"],
- addr_cc: ["Lisa <lisa@example.com>"],
- addr_bcc: ["Moe <moe@example.com>"],
- addr_reply: ["Flanders <flanders@example.com>"],
- }
- );
-
- useAutoCc(identity, myEmail + ", smithers@example.com");
- useAutoBcc(identity, "Lisa <lisa@example.com>");
- checkReply(
- open_compose_with_reply_to_all,
- // To: original To
- // Cc: original Cc (auto-Ccs would have been included here already)
- // Bcc: original Bcc
- // Reply-To: original Reply-To
- {
- addr_to: ["Bart <bart@example.com>", "Maggie <maggie@example.com>"],
- addr_cc: ["Lisa <lisa@example.com>"],
- addr_bcc: ["Moe <moe@example.com>"],
- addr_reply: ["Flanders <flanders@example.com>"],
- }
- );
- stopUsingAutoCc(identity);
- stopUsingAutoBcc(identity);
-}
-
-/**
- * Tests that addresses get set properly for a reply all to self - but for a
- * message that is not really the original sent message. Like an auto-bcc:d copy
- * or from Gmail. This should be treated as a followup.
- */
-function testReplyToSelfNotOriginalSourceMsgReplyAll() {
- let msg0 = create_message({
- from: myEmail2,
- to: "Bart <bart@example.com>, Maggie <maggie@example.com>",
- cc: "Lisa <lisa@example.com>",
- subject: "testReplyToSelfNotOriginalSourceMsgReplyAll - reply to self",
- clobberHeaders: {
- "Reply-To": "Flanders <flanders@example.com>",
- },
- });
- add_message_to_folder(folder, msg0);
-
- be_in_folder(folder);
- let msg = select_click_row(i++);
- assert_selected_and_displayed(mc, msg);
-
- ensureNoAutoCc(identity2);
- useAutoBcc(identity2, myEmail + ", smithers@example.com");
- checkReply(
- open_compose_with_reply_to_all,
- // To: original To
- // Cc: original Cc
- // Bcc: auto-bccs
- // Reply-To: original Reply-To
- {
- addr_to: ["Bart <bart@example.com>", "Maggie <maggie@example.com>"],
- addr_cc: ["Lisa <lisa@example.com>"],
- addr_bcc: [myEmail, "smithers@example.com"],
- addr_reply: ["Flanders <flanders@example.com>"],
- }
- );
- stopUsingAutoBcc(identity2);
-
- useAutoCc(identity2, myEmail + ", smithers@example.com");
- useAutoBcc(identity2, "moe@example.com,bart@example.com,lisa@example.com");
- checkReply(
- open_compose_with_reply_to_all,
- // To: original To
- // Cc: original Cc (auto-Ccs would have been included here already)
- // Bcc: auto-bcc minus addresses already in To/Cc
- // Reply-To: original Reply-To
- {
- addr_to: ["Bart <bart@example.com>", "Maggie <maggie@example.com>"],
- addr_cc: ["Lisa <lisa@example.com>", myEmail, "smithers@example.com"],
- addr_bcc: ["moe@example.com"],
- addr_reply: ["Flanders <flanders@example.com>"],
- }
- );
- stopUsingAutoCc(identity2);
- stopUsingAutoBcc(identity2);
-
- useAutoBcc(identity2, myEmail2 + ", smithers@example.com");
- checkReply(
- open_compose_with_reply_to_all,
- // To: original To
- // Cc: original Cc (auto-Ccs would have been included here already)
- // Bcc: auto-bccs
- // Reply-To: original Reply-To
- {
- addr_to: ["Bart <bart@example.com>", "Maggie <maggie@example.com>"],
- addr_cc: ["Lisa <lisa@example.com>"],
- addr_bcc: [myEmail2, "smithers@example.com"],
- addr_reply: ["Flanders <flanders@example.com>"],
- }
- );
- stopUsingAutoBcc(identity2);
-}
-
-/**
- * Tests that a reply to an other identity isn't treated as a reply to self
- * followup.
- */
-function testReplyToOtherIdentity() {
- let msg0 = create_message({
- from: myEmail,
- to: myEmail2 + ", barney@example.com",
- cc: "Lisa <lisa@example.com>",
- subject: "testReplyToOtherIdentity - reply to other identity",
- clobberHeaders: {
- "Reply-To": "secretary@example.com",
- },
- });
- add_message_to_folder(folder, msg0);
-
- be_in_folder(folder);
- let msg = select_click_row(i++);
- assert_selected_and_displayed(mc, msg);
-
- ensureNoAutoCc(identity2);
- ensureNoAutoBcc(identity2);
- checkReply(
- open_compose_with_reply_to_all,
- // To: from + to (except me2)
- // Cc: original Cc
- //
- {
- addr_to: ["secretary@example.com", "barney@example.com"],
- addr_cc: ["Lisa <lisa@example.com>"],
- }
- );
-}
-
-/**
- * Tests that addresses get set properly for a reply all to self w/ bccs -
- * this should be treated as a followup.
- */
-function testReplyToSelfWithBccs() {
- let msg0 = create_message({
- from: myEmail,
- to: myEmail,
- cc: myEmail2 + ", Lisa <lisa@example.com>",
- subject: "testReplyToSelfWithBccs - reply to self",
- clobberHeaders: {
- Bcc: "Moe <moe@example.com>, Barney <barney@example.com>",
- "Reply-To": myEmail2,
- },
- });
- add_message_to_folder(folder, msg0);
-
- be_in_folder(folder);
- let msg = select_click_row(i++);
- assert_selected_and_displayed(mc, msg);
-
- ensureNoAutoCc(identity);
- checkReply(
- open_compose_with_reply_to_all,
- // To: original To
- // Cc: original Cc
- // Bcc: original Bcc
- // Reply-To: original Reply-To
- {
- addr_to: [myEmail],
- addr_cc: [myEmail2, "Lisa <lisa@example.com>"],
- addr_bcc: ["Moe <moe@example.com>", "Barney <barney@example.com>"],
- addr_reply: [myEmail2],
- }
- );
-}
-
-/**
- * Tests that addresses get set properly for a reply all to other identity w/ bccs -
- * this be treated as a followup.
- */
-function testReplyToOtherIdentityWithBccs() {
- let msg0 = create_message({
- from: myEmail,
- to: myEmail2,
- cc: "Lisa <lisa@example.com>",
- subject: "testReplyToOtherIdentityWithBccs - reply to other identity",
- clobberHeaders: {
- Bcc: "Moe <moe@example.com>, Barney <barney@example.com>",
- },
- });
- add_message_to_folder(folder, msg0);
-
- be_in_folder(folder);
- let msg = select_click_row(i++);
- assert_selected_and_displayed(mc, msg);
-
- ensureNoAutoCc(identity);
- checkReply(
- open_compose_with_reply_to_all,
- // To: original To
- // Cc: original Cc
- // Bcc: original Bcc
- {
- addr_to: [myEmail2],
- addr_cc: ["Lisa <lisa@example.com>"],
- addr_bcc: ["Moe <moe@example.com>", "Barney <barney@example.com>"],
- }
- );
-}
-
-/**
- * Tests that addresses get set properly for a nntp reply-all.
- */
-function testNewsgroupsReplyAll() {
- let msg0 = create_message({
- from: "Homer <homer@example.com>",
- to: "test1-list@example.org",
- subject: "testNewsgroupsReplyAll - sent to two newsgroups and a list",
- clobberHeaders: {
- Newsgroups: "example.test1, example.test2",
- },
- });
- add_message_to_folder(folder, msg0);
-
- be_in_folder(folder);
- let msg = select_click_row(i++);
- assert_selected_and_displayed(mc, msg);
-
- ensureNoAutoCc(identity);
- checkReply(
- open_compose_with_reply_to_all,
- // To: From, original To
- // Newsgroups: original Ccs
- {
- addr_to: ["Homer <homer@example.com>", "test1-list@example.org"],
- addr_newsgroups: ["example.test1", "example.test2"],
- }
- );
-
- useAutoCc(identity, myEmail + ", smithers@example.com");
- checkReply(
- open_compose_with_reply_to_all,
- // To: From, original To
- // Newsgroups: original Ccs
- {
- addr_to: ["Homer <homer@example.com>", "test1-list@example.org"],
- addr_cc: [myEmail, "smithers@example.com"],
- addr_newsgroups: ["example.test1", "example.test2"],
- }
- );
- stopUsingAutoCc(identity);
-}
-
-/**
- * Tests that addresses get set properly for an nntp followup, when Followup-To
- * is set.
- */
-function testNewsgroupsReplyAllFollowupTo() {
- let msg0 = create_message({
- from: "Homer <homer@example.com>",
- to: "test1-list@example.org, " + myEmail,
- subject: "testNewsgroupsReplyAllFollowupTo - Followup-To set",
- clobberHeaders: {
- Newsgroups: "example.test1, example.test2",
- "Followup-To": "example.test2",
- },
- });
- add_message_to_folder(folder, msg0);
-
- be_in_folder(folder);
- let msg = select_click_row(i++);
- assert_selected_and_displayed(mc, msg);
-
- ensureNoAutoCc(identity);
- checkReply(
- open_compose_with_reply_to_all,
- // To: From + original To (except me)
- // Newsgroups: <Followup-To>
- {
- addr_to: ["Homer <homer@example.com>", "test1-list@example.org"],
- addr_newsgroups: ["example.test2"],
- }
- );
-
- useAutoCc(identity, myEmail + ", smithers@example.com");
- checkReply(
- open_compose_with_reply_to_all,
- // To: From + original To (except me)
- // Cc: auto-Ccs
- // Newsgroups: <Followup-To>
- {
- addr_to: ["Homer <homer@example.com>", "test1-list@example.org"],
- addr_cc: [myEmail, "smithers@example.com"],
- addr_newsgroups: ["example.test2"],
- }
- );
- stopUsingAutoCc(identity);
-}
-
-/**
- * Tests that addresses get set properly when doing a reply where To=From
- * and a Reply-To exists.
- */
-function testToFromWithReplyTo() {
- let msg0 = create_message({
- from: myEmail,
- to: myEmail,
- subject: "testToFromWithReplyTo - To=From w/ Reply-To set",
- clobberHeaders: { "Reply-To": "Flanders <flanders@example.com>" },
- });
- add_message_to_folder(folder, msg0);
-
- be_in_folder(folder);
- let msg = select_click_row(i++);
- assert_selected_and_displayed(mc, msg);
-
- ensureNoAutoCc(identity);
- checkReply(
- open_compose_with_reply,
- // To: Reply-To
- { addr_to: ["Flanders <flanders@example.com>"] }
- );
-}
deleted file mode 100644
--- a/mail/test/mozmill/composition/test-reply-format-flowed.js
+++ /dev/null
@@ -1,88 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests that the reply to a format=flowed message is also flowed.
- */
-
-"use strict";
-
-var os = ChromeUtils.import("chrome://mozmill/content/stdlib/os.jsm");
-
-var {
- close_compose_window,
- get_msg_source,
- open_compose_with_reply,
-} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
-var {
- assert_true,
- be_in_folder,
- get_special_folder,
- open_message_from_file,
- press_delete,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { close_window } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-var gDrafts;
-
-function setupModule(module) {
- gDrafts = get_special_folder(Ci.nsMsgFolderFlags.Drafts, true);
-
- Services.prefs.setBoolPref("mail.identity.id1.compose_html", false);
-}
-
-function subtest_reply_format_flowed(aFlowed) {
- let file = os.getFileForPath(
- os.abspath("./format-flowed.eml", os.getFileForPath(__file__))
- );
- let msgc = open_message_from_file(file);
-
- Services.prefs.setBoolPref("mailnews.send_plaintext_flowed", aFlowed);
-
- let cwc = open_compose_with_reply(msgc);
-
- close_window(msgc);
-
- // Now save the message as a draft.
- cwc.keypress(null, "s", { shiftKey: false, accelKey: true });
- close_compose_window(cwc);
-
- // Now check the message content in the drafts folder.
- be_in_folder(gDrafts);
- let message = select_click_row(0);
- let messageContent = get_msg_source(message);
-
- // Check for a single line that contains text and make sure there is a
- // space at the end for a flowed reply.
- assert_true(
- messageContent.includes(
- "\r\n> text text text text text text text text text text text text text text" +
- (aFlowed ? " \r\n" : "\r\n")
- ),
- "Expected line not found in message."
- );
-
- // Delete the outgoing message.
- press_delete();
-}
-
-function test_reply_format_flowed() {
- subtest_reply_format_flowed(true);
- subtest_reply_format_flowed(false);
-}
-
-function teardownModule() {
- Services.prefs.clearUserPref("mail.identity.id1.compose_html");
- Services.prefs.clearUserPref("mailnews.send_plaintext_flowed");
-}
deleted file mode 100644
--- a/mail/test/mozmill/composition/test-reply-multipart-charset.js
+++ /dev/null
@@ -1,212 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * This has become a "mixed bag" of tests for various bugs.
- *
- * Bug 1026989:
- * Tests that the reply to a message picks up the charset from the body
- * and not from an attachment. Also test "Edit as new", forward inline and
- * forward as attachment.
- *
- * Bug 961983:
- * Tests that UTF-16 is not used in a composition.
- *
- * Bug 1323377:
- * Tests that the correct charset is used, even if the message
- * wasn't viewed before answering/forwarding.
- * For good measure some tests are included for charset overriding
- * and enforcing the charset default.
- */
-
-"use strict";
-
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-var os = ChromeUtils.import("chrome://mozmill/content/stdlib/os.jsm");
-
-var {
- close_compose_window,
- open_compose_with_edit_as_new,
- open_compose_with_forward,
- open_compose_with_forward_as_attachments,
- open_compose_with_reply,
-} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
-var {
- assert_equals,
- assert_selected_and_displayed,
- be_in_folder,
- create_folder,
- mc,
- open_message_from_file,
- press_delete,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { close_window } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var folderToStoreMessages;
-
-function setupModule(module) {
- folderToStoreMessages = create_folder("FolderWithMessages");
-}
-
-function subtest_replyEditAsNewForward_charset(
- aAction,
- aFile,
- aCharset,
- aOverride = null,
- aViewed = true
-) {
- be_in_folder(folderToStoreMessages);
-
- let file = os.getFileForPath(os.abspath(aFile, os.getFileForPath(__file__)));
- let msgc = open_message_from_file(file);
-
- // Copy the message to a folder. We run the message through a folder
- // since replying/editing as new/forwarding directly to the message
- // opened from a file gives different results on different platforms.
- // All platforms behave the same when using a folder-stored message.
- let documentChild = msgc.e("messagepane").contentDocument.firstChild;
- msgc.rightClick(new elib.Elem(documentChild));
- msgc.click_menus_in_sequence(msgc.e("mailContext"), [
- { id: "mailContext-copyMenu" },
- { label: "Local Folders" },
- { label: "FolderWithMessages" },
- ]);
- close_window(msgc);
-
- let msg = select_click_row(0);
- if (aViewed) {
- // Only if the preview pane is on, we can check the following.
- assert_selected_and_displayed(mc, msg);
- }
-
- if (aOverride) {
- // Display the message using the override charset.
- // Use the app menu which is also available on Mac.
- mc.click_through_appmenu([{ label: "View" }, { label: "Text Encoding" }], {
- label: aOverride,
- });
- }
-
- let fwdWin;
- switch (aAction) {
- case 1: // Reply.
- fwdWin = open_compose_with_reply();
- break;
- case 2: // Edit as new.
- fwdWin = open_compose_with_edit_as_new();
- break;
- case 3: // Forward inline.
- fwdWin = open_compose_with_forward();
- break;
- case 4: // Forward as attachment.
- fwdWin = open_compose_with_forward_as_attachments();
- break;
- }
-
- // Check the charset in the compose window.
- let charset = fwdWin.e("content-frame").contentDocument.charset;
- assert_equals(charset, aCharset, "Compose window has the wrong charset");
- close_compose_window(fwdWin);
-
- press_delete(mc);
-}
-
-function test_replyEditAsNewForward_charsetFromBody() {
- // Check that the charset is taken from the message body (bug 1026989).
- subtest_replyEditAsNewForward_charset(1, "./multipart-charset.eml", "EUC-KR");
- subtest_replyEditAsNewForward_charset(2, "./multipart-charset.eml", "EUC-KR");
- subtest_replyEditAsNewForward_charset(3, "./multipart-charset.eml", "EUC-KR");
- // For "forward as attachment" we use the default charset (which is UTF-8).
- subtest_replyEditAsNewForward_charset(4, "./multipart-charset.eml", "UTF-8");
-}
-
-function test_reply_noUTF16() {
- // Check that a UTF-16 encoded e-mail is forced to UTF-8 when replying (bug 961983).
- subtest_replyEditAsNewForward_charset(1, "./body-utf16.eml", "UTF-8");
-}
-
-function test_replyEditAsNewForward_override() {
- // Check that the override is honoured (inspired by bug 1323377).
- subtest_replyEditAsNewForward_charset(
- 1,
- "./multipart-charset.eml",
- "UTF-8",
- "Unicode"
- );
- subtest_replyEditAsNewForward_charset(
- 2,
- "./multipart-charset.eml",
- "windows-1252",
- "Western"
- );
- subtest_replyEditAsNewForward_charset(
- 3,
- "./multipart-charset.eml",
- "ISO-8859-7",
- "Greek (ISO)"
- );
-}
-
-function test_replyEditAsNewForward_enforceDefault() {
- // Check that the default is honoured (inspired by bug 1323377).
- Services.prefs.setBoolPref("mailnews.reply_in_default_charset", true);
- Services.prefs.setCharPref("mailnews.send_default_charset", "ISO-8859-7");
- subtest_replyEditAsNewForward_charset(
- 1,
- "./multipart-charset.eml",
- "ISO-8859-7"
- );
- subtest_replyEditAsNewForward_charset(
- 2,
- "./multipart-charset.eml",
- "ISO-8859-7"
- );
- subtest_replyEditAsNewForward_charset(
- 3,
- "./multipart-charset.eml",
- "ISO-8859-7"
- );
- Services.prefs.clearUserPref("mailnews.reply_in_default_charset");
- Services.prefs.clearUserPref("mailnews.send_default_charset");
-}
-
-function test_replyEditAsNewForward_noPreview() {
- // Check that it works even if the message wasn't viewed before, so
- // switch off the preview pane (bug 1323377).
- be_in_folder(folderToStoreMessages);
- mc.window.goDoCommand("cmd_toggleMessagePane");
-
- subtest_replyEditAsNewForward_charset(
- 1,
- "./format-flowed.eml",
- "windows-1252",
- null,
- false
- );
- subtest_replyEditAsNewForward_charset(
- 2,
- "./body-greek.eml",
- "ISO-8859-7",
- null,
- false
- );
- subtest_replyEditAsNewForward_charset(
- 3,
- "./multipart-charset.eml",
- "EUC-KR",
- null,
- false
- );
-
- mc.window.goDoCommand("cmd_toggleMessagePane");
-}
deleted file mode 100644
--- a/mail/test/mozmill/composition/test-reply-signature.js
+++ /dev/null
@@ -1,113 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests the mail.strip_sig_on_reply pref.
- */
-
-"use strict";
-
-var {
- close_compose_window,
- get_compose_body,
- open_compose_with_reply,
-} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
-var {
- add_message_to_folder,
- assert_selected_and_displayed,
- be_in_folder,
- create_folder,
- create_message,
- mc,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var sig = "roses are red";
-var folder;
-
-function setupModule(module) {
- folder = create_folder("SigStripTest");
-
- let msg = create_message({
- subject: "msg with signature; format=flowed",
- body: {
- body:
- "get with the flow! get with the flow! get with the flow! " +
- "get with the \n flow! get with the flow!\n-- \n" +
- sig +
- "\n",
- contentType: "text/plain",
- charset: "UTF-8",
- format: "flowed",
- },
- });
- add_message_to_folder(folder, msg);
- let msg2 = create_message({
- subject: "msg with signature; format not flowed",
- body: {
- body:
- "not flowed! not flowed! not flowed! \n" +
- "not flowed!\n-- \n" +
- sig +
- "\n",
- contentType: "text/plain",
- charset: "UTF-8",
- format: "",
- },
- });
- add_message_to_folder(folder, msg2);
-}
-
-/** Test sig strip true for format flowed. */
-function test_sig_strip_true_ff() {
- Services.prefs.setBoolPref("mail.strip_sig_on_reply", true);
- check_sig_strip_works(0, true);
- Services.prefs.clearUserPref("mail.strip_sig_on_reply");
-}
-
-/** Test sig strip false for format flowed. */
-function test_sig_strip_false_ff() {
- Services.prefs.setBoolPref("mail.strip_sig_on_reply", false);
- check_sig_strip_works(0, false);
- Services.prefs.clearUserPref("mail.strip_sig_on_reply");
-}
-
-/** Test sig strip true for non-format flowed. */
-function test_sig_strip_true_nonff() {
- Services.prefs.setBoolPref("mail.strip_sig_on_reply", true);
- check_sig_strip_works(1, true);
- Services.prefs.clearUserPref("mail.strip_sig_on_reply");
-}
-
-/** Test sig strip false for non-format flowed. */
-function test_sig_strip_false_nonff() {
- Services.prefs.setBoolPref("mail.strip_sig_on_reply", false);
- check_sig_strip_works(1, false);
- Services.prefs.clearUserPref("mail.strip_sig_on_reply");
-}
-
-/**
- * Helper function to check signature stripping works as it should.
- * @param aRow the row index of the message to test
- * @param aShouldStrip true if the signature should be stripped
- */
-function check_sig_strip_works(aRow, aShouldStrip) {
- be_in_folder(folder);
- let msg = select_click_row(aRow);
- assert_selected_and_displayed(mc, msg);
-
- let rwc = open_compose_with_reply();
- let body = get_compose_body(rwc);
-
- if (aShouldStrip && body.textContent.includes(sig)) {
- throw new Error("signature was not stripped; body=" + body.textContent);
- } else if (!aShouldStrip && !body.textContent.includes(sig)) {
- throw new Error("signature stripped; body=" + body.textContent);
- }
- close_compose_window(rwc);
-}
deleted file mode 100644
--- a/mail/test/mozmill/composition/test-save-changes-on-quit.js
+++ /dev/null
@@ -1,309 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests that we prompt the user if they'd like to save their message when they
- * try to quit/close with an open compose window with unsaved changes, and
- * that we don't prompt if there are no changes.
- */
-
-"use strict";
-
-var {
- close_compose_window,
- open_compose_new_mail,
- open_compose_with_forward,
- open_compose_with_reply,
-} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
-var {
- add_message_to_folder,
- assert_equals,
- assert_false,
- assert_not_equals,
- assert_selected_and_displayed,
- assert_true,
- be_in_folder,
- create_folder,
- create_message,
- mc,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { gMockPromptService } = ChromeUtils.import(
- "resource://testing-common/mozmill/PromptHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var SAVE = 0;
-var CANCEL = 1;
-var DONT_SAVE = 2;
-
-var cwc = null; // compose window controller
-var folder = null;
-
-function setupModule(module) {
- folder = create_folder("PromptToSaveTest");
-
- add_message_to_folder(folder, create_message()); // row 0
- let localFolder = folder.QueryInterface(Ci.nsIMsgLocalMailFolder);
- localFolder.addMessage(msgSource("content type: text", "text")); // row 1
- localFolder.addMessage(msgSource("content type missing", null)); // row 2
-}
-
-function msgSource(aSubject, aContentType) {
- let msgId =
- Cc["@mozilla.org/uuid-generator;1"]
- .getService(Ci.nsIUUIDGenerator)
- .generateUUID() + "@invalid";
-
- return (
- "From - Sun Apr 07 22:47:11 2013\r\n" +
- "X-Mozilla-Status: 0001\r\n" +
- "X-Mozilla-Status2: 00000000\r\n" +
- "Message-ID: <" +
- msgId +
- ">\r\n" +
- "Date: Sun, 07 Apr 2013 22:47:11 +0300\r\n" +
- "From: Someone <some.one@invalid>\r\n" +
- "To: someone.else@invalid\r\n" +
- "Subject: " +
- aSubject +
- "\r\n" +
- "MIME-Version: 1.0\r\n" +
- (aContentType ? "Content-Type: " + aContentType + "\r\n" : "") +
- "Content-Transfer-Encoding: 7bit\r\n\r\n" +
- "A msg with contentType " +
- aContentType +
- "\r\n"
- );
-}
-
-/**
- * Test that when a compose window is open with changes, and
- * a Quit is requested (for example, from File > Quit from the
- * 3pane), that the user gets a confirmation dialog to discard
- * the changes. This also tests that the user can cancel the
- * quit request.
- */
-function test_can_cancel_quit_on_changes() {
- // Register the Mock Prompt Service
- gMockPromptService.register();
-
- // opening a new compose window
- cwc = open_compose_new_mail(mc);
-
- // Make some changes
- cwc.type(cwc.eid("content-frame"), "Hey check out this megalol link");
-
- let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance(
- Ci.nsISupportsPRBool
- );
-
- // Set the Mock Prompt Service to return false, so that we
- // cancel the quit.
- gMockPromptService.returnValue = CANCEL;
- // Trigger the quit-application-request notification
-
- Services.obs.notifyObservers(cancelQuit, "quit-application-requested");
-
- let promptState = gMockPromptService.promptState;
- assert_not_equals(null, promptState, "Expected a confirmEx prompt");
-
- assert_equals("confirmEx", promptState.method);
- // Since we returned false on the confirmation dialog,
- // we should be cancelling the quit - so cancelQuit.data
- // should now be true
- assert_true(cancelQuit.data, "Didn't cancel the quit");
-
- close_compose_window(cwc);
-
- // Unregister the Mock Prompt Service
- gMockPromptService.unregister();
-}
-
-/**
- * Test that when a compose window is open with changes, and
- * a Quit is requested (for example, from File > Quit from the
- * 3pane), that the user gets a confirmation dialog to discard
- * the changes. This also tests that the user can let the quit
- * occur.
- */
-function test_can_quit_on_changes() {
- // Register the Mock Prompt Service
- gMockPromptService.register();
-
- // opening a new compose window
- cwc = open_compose_new_mail(mc);
-
- // Make some changes
- cwc.type(cwc.eid("content-frame"), "Hey check out this megalol link");
-
- let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance(
- Ci.nsISupportsPRBool
- );
-
- // Set the Mock Prompt Service to return true, so that we're
- // allowing the quit to occur.
- gMockPromptService.returnValue = DONT_SAVE;
-
- // Trigger the quit-application-request notification
- Services.obs.notifyObservers(cancelQuit, "quit-application-requested");
-
- let promptState = gMockPromptService.promptState;
- assert_not_equals(null, promptState, "Expected a confirmEx prompt");
-
- assert_equals("confirmEx", promptState.method);
- // Since we returned true on the confirmation dialog,
- // we should be quitting - so cancelQuit.data should now be
- // false
- assert_false(cancelQuit.data, "The quit request was cancelled");
-
- close_compose_window(cwc);
-
- // Unregister the Mock Prompt Service
- gMockPromptService.unregister();
-}
-
-/**
- * Bug 698077 - test that when quitting with two compose windows open, if
- * one chooses "Don't Save", and the other chooses "Cancel", that the first
- * window's state is such that subsequent quit requests still cause the
- * Don't Save / Cancel / Save dialog to come up.
- */
-function test_window_quit_state_reset_on_aborted_quit() {
- // Register the Mock Prompt Service
- gMockPromptService.register();
-
- // open two new compose windows
- let cwc1 = open_compose_new_mail(mc);
- let cwc2 = open_compose_new_mail(mc);
-
- // Type something in each window.
- cwc1.type(cwc1.eid("content-frame"), "Marco!");
- cwc2.type(cwc2.eid("content-frame"), "Polo!");
-
- let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance(
- Ci.nsISupportsPRBool
- );
-
- // This is a hacky method for making sure that the second window
- // receives a CANCEL click in the popup dialog.
- var numOfPrompts = 0;
- gMockPromptService.onPromptCallback = function() {
- numOfPrompts++;
-
- if (numOfPrompts > 1) {
- gMockPromptService.returnValue = CANCEL;
- }
- };
-
- gMockPromptService.returnValue = DONT_SAVE;
-
- // Trigger the quit-application-request notification
- Services.obs.notifyObservers(cancelQuit, "quit-application-requested");
-
- // We should have cancelled the quit appropriately.
- assert_true(cancelQuit.data);
-
- // The quit behaviour is that the second window to spawn is the first
- // one that prompts for Save / Don't Save, etc.
- gMockPromptService.reset();
-
- // The first window should still prompt when attempting to close the
- // window.
- gMockPromptService.returnValue = DONT_SAVE;
- cwc2.click(cwc2.eid("menu_close"));
-
- let promptState = gMockPromptService.promptState;
- assert_not_equals(null, promptState, "Expected a confirmEx prompt");
-
- close_compose_window(cwc1);
-
- gMockPromptService.unregister();
-}
-
-/**
- * Tests that we don't get a prompt to save if there has been no user input
- * into the message yet, when trying to close.
- */
-function test_no_prompt_on_close_for_unmodified() {
- be_in_folder(folder);
- let msg = select_click_row(0);
- assert_selected_and_displayed(mc, msg);
-
- let nwc = open_compose_new_mail();
- close_compose_window(nwc, false);
-
- let rwc = open_compose_with_reply();
- close_compose_window(rwc, false);
-
- let fwc = open_compose_with_forward();
- close_compose_window(fwc, false);
-}
-
-/**
- * Tests that we get a prompt to save if the user made changes to the message
- * before trying to close it.
- */
-function test_prompt_on_close_for_modified() {
- be_in_folder(folder);
- let msg = select_click_row(0);
- assert_selected_and_displayed(mc, msg);
-
- let nwc = open_compose_new_mail();
- nwc.type(nwc.eid("content-frame"), "Hey hey hey!");
- close_compose_window(nwc, true);
-
- let rwc = open_compose_with_reply();
- rwc.type(rwc.eid("content-frame"), "Howdy!");
- close_compose_window(rwc, true);
-
- let fwc = open_compose_with_forward();
- fwc.type(fwc.eid("content-frame"), "Greetings!");
- close_compose_window(fwc, true);
-}
-
-/**
- * Test there's no prompt on close when no changes was made in reply/forward
- * windows - for the case the original msg had content type "text".
- */
-function test_no_prompt_on_close_for_unmodified_content_type_text() {
- be_in_folder(folder);
- let msg = select_click_row(1); // row 1 is the one with content type text
- assert_selected_and_displayed(mc, msg);
-
- let rwc = open_compose_with_reply();
- close_compose_window(rwc, false);
-
- let fwc = open_compose_with_forward();
- assert_equals(
- fwc.e("attachmentBucket").getRowCount(),
- 0,
- "forwarding msg created attachment"
- );
- close_compose_window(fwc, false);
-}
-
-/**
- * Test there's no prompt on close when no changes was made in reply/forward
- * windows - for the case the original msg had no content type.
- */
-function test_no_prompt_on_close_for_unmodified_no_content_type() {
- be_in_folder(folder);
- let msg = select_click_row(2); // row 2 is the one with no content type
- assert_selected_and_displayed(mc, msg);
-
- let rwc = open_compose_with_reply();
- close_compose_window(rwc, false);
-
- let fwc = open_compose_with_forward();
- assert_equals(
- fwc.e("attachmentBucket").getRowCount(),
- 0,
- "forwarding msg created attachment"
- );
- close_compose_window(fwc, false);
-}
deleted file mode 100644
--- a/mail/test/mozmill/composition/test-send-button.js
+++ /dev/null
@@ -1,283 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests proper enabling of send buttons depending on addresses input.
- */
-
-"use strict";
-
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-var utils = ChromeUtils.import("chrome://mozmill/content/modules/utils.jsm");
-
-var {
- create_contact,
- create_mailing_list,
- load_contacts_into_address_book,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/AddressBookHelpers.jsm"
-);
-var {
- assert_equals,
- assert_false,
- assert_true,
- be_in_folder,
- click_tree_row,
- FAKE_SERVER_HOSTNAME,
- get_special_folder,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var {
- clear_recipient,
- get_first_pill,
- close_compose_window,
- open_compose_new_mail,
- setup_msg_contents,
- toggle_recipient_type,
-} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
-var { wait_for_frame_load } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { AppConstants } = ChromeUtils.import(
- "resource://gre/modules/AppConstants.jsm"
-);
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-var account = null;
-
-function setupModule(module) {
- // Ensure we're in the tinderbox account as that has the right identities set
- // up for this test.
- let server = MailServices.accounts.FindServer(
- "tinderbox",
- FAKE_SERVER_HOSTNAME,
- "pop3"
- );
- account = MailServices.accounts.FindAccountForServer(server);
- let inbox = get_special_folder(Ci.nsMsgFolderFlags.Inbox, false, server);
- be_in_folder(inbox);
-}
-
-/**
- * Check if the send commands are in the wished state.
- *
- * @param aCwc The compose window controller.
- * @param aEnabled The expected state of the commands.
- */
-function check_send_commands_state(aCwc, aEnabled) {
- assert_equals(aCwc.e("cmd_sendButton").hasAttribute("disabled"), !aEnabled);
- assert_equals(aCwc.e("cmd_sendNow").hasAttribute("disabled"), !aEnabled);
- assert_equals(
- aCwc.e("cmd_sendWithCheck").hasAttribute("disabled"),
- !aEnabled
- );
- assert_equals(aCwc.e("cmd_sendLater").hasAttribute("disabled"), !aEnabled);
-
- // The toolbar buttons and menuitems should be linked to these commands
- // thus inheriting the enabled state. Check that on the Send button
- // and Send Now menuitem.
- assert_equals(
- aCwc.e("button-send").getAttribute("command"),
- "cmd_sendButton"
- );
- assert_equals(
- aCwc.e("menu-item-send-now").getAttribute("command"),
- "cmd_sendNow"
- );
-}
-
-/**
- * Bug 431217
- * Test that the Send buttons are properly enabled if an addressee is input
- * by the user.
- */
-function test_send_enabled_manual_address() {
- let cwc = open_compose_new_mail(); // compose controller
- // On an empty window, Send must be disabled.
- check_send_commands_state(cwc, false);
-
- // On valid "To:" addressee input, Send must be enabled.
- setup_msg_contents(cwc, " recipient@fake.invalid ", "", "");
- check_send_commands_state(cwc, true);
-
- // When the addressee is not in To, Cc, Bcc or Newsgroup, disable Send again.
- clear_recipient(cwc);
- cwc.click(cwc.eid("addr_reply"));
- setup_msg_contents(cwc, " recipient@fake.invalid ", "", "", "replyAddrInput");
- check_send_commands_state(cwc, false);
-
- clear_recipient(cwc);
- check_send_commands_state(cwc, false);
-
- // Bug 1296535
- // Try some other invalid and valid recipient strings:
- // - random string that is no email.
- setup_msg_contents(cwc, " recipient@", "", "");
- check_send_commands_state(cwc, false);
-
- cwc.click(cwc.eid("addr_cc"));
- check_send_commands_state(cwc, false);
-
- // Select the newly generated pill.
- cwc.click(get_first_pill(cwc));
- // Delete the selected pill.
- cwc.keypress(null, "VK_DELETE", {});
- // Confirm the address row is now empty.
- assert_true(!get_first_pill(cwc).length);
- // Confirm the send button is disabled.
- check_send_commands_state(cwc, false);
-
- // Add multiple recipients.
- setup_msg_contents(
- cwc,
- "recipient@domain.invalid, info@somedomain.extension, name@incomplete",
- "",
- ""
- );
- check_send_commands_state(cwc, true);
-
- clear_recipient(cwc);
- check_send_commands_state(cwc, false);
-
- // - a mailinglist in addressbook
- // Button is enabled without checking whether it contains valid addresses.
- let defaultAB = MailServices.ab.getDirectory("jsaddrbook://abook.sqlite");
- let ml = create_mailing_list("emptyList");
- defaultAB.addMailList(ml);
-
- setup_msg_contents(cwc, " emptyList", "", "");
- check_send_commands_state(cwc, true);
-
- clear_recipient(cwc);
- check_send_commands_state(cwc, false);
-
- setup_msg_contents(cwc, "emptyList <list> ", "", "");
- check_send_commands_state(cwc, true);
-
- clear_recipient(cwc);
- check_send_commands_state(cwc, false);
-
- // - some string as a newsgroup
- cwc.e("addr_newsgroups").removeAttribute("collapsed");
- cwc.click(cwc.eid("addr_newsgroups"));
- setup_msg_contents(cwc, "newsgroup ", "", "", "newsgroupsAddrInput");
- check_send_commands_state(cwc, true);
-
- close_compose_window(cwc);
-}
-
-/**
- * Bug 431217
- * Test that the Send buttons are properly enabled if an addressee is prefilled
- * automatically via account prefs.
- */
-function test_send_enabled_prefilled_address() {
- // Set the prefs to prefill a default CC address when Compose is opened.
- let identity = account.defaultIdentity;
- identity.doCc = true;
- identity.doCcList = "Auto@recipient.invalid";
-
- // In that case the recipient is input, enabled Send.
- let cwc = open_compose_new_mail(); // compose controller
- check_send_commands_state(cwc, true);
-
- // Clear the CC list.
- clear_recipient(cwc);
- // No other pill is there. Send should become disabled.
- check_send_commands_state(cwc, false);
-
- close_compose_window(cwc);
- identity.doCcList = "";
- identity.doCc = false;
-}
-
-/**
- * Bug 933101
- * Similar to test_send_enabled_prefilled_address but switched between an identity
- * that has a CC list and one that doesn't directly in the compose window.
- */
-function test_send_enabled_prefilled_address_from_identity() {
- // The first identity will have an automatic CC enabled.
- let identityWithCC = account.defaultIdentity;
- identityWithCC.doCc = true;
- identityWithCC.doCcList = "Auto@recipient.invalid";
-
- // CC is prefilled, Send enabled.
- let cwc = open_compose_new_mail();
- check_send_commands_state(cwc, true);
-
- let identityPicker = cwc.e("msgIdentity");
- assert_equals(identityPicker.selectedIndex, 0);
-
- // Switch to the second identity that has no CC. Send should be disabled.
- assert_true(account.identities.length >= 2);
- let identityWithoutCC = account.identities.queryElementAt(
- 1,
- Ci.nsIMsgIdentity
- );
- assert_false(identityWithoutCC.doCc);
- cwc.click(cwc.eid("msgIdentity"));
- cwc.click_menus_in_sequence(cwc.e("msgIdentityPopup"), [
- { identitykey: identityWithoutCC.key },
- ]);
- check_send_commands_state(cwc, false);
-
- // Check the first identity again.
- cwc.click(cwc.eid("msgIdentity"));
- cwc.click_menus_in_sequence(cwc.e("msgIdentityPopup"), [
- { identitykey: identityWithCC.key },
- ]);
- check_send_commands_state(cwc, true);
-
- close_compose_window(cwc);
- identityWithCC.doCcList = "";
- identityWithCC.doCc = false;
-}
-
-/**
- * Bug 863231
- * Test that the Send buttons are properly enabled if an addressee is populated
- * via the Contacts sidebar.
- */
-function test_send_enabled_address_contacts_sidebar() {
- // Create some contact address book card in the Personal addressbook.
- let defaultAB = MailServices.ab.getDirectory("jsaddrbook://abook.sqlite");
- let contact = create_contact("test@example.com", "Sammy Jenkis", true);
- load_contacts_into_address_book(defaultAB, [contact]);
-
- let cwc = open_compose_new_mail(); // compose controller
- // On an empty window, Send must be disabled.
- check_send_commands_state(cwc, false);
-
- // Open Contacts sidebar and use our contact.
- cwc.window.toggleAddressPicker();
-
- let sidebar = cwc.e("sidebar");
- wait_for_frame_load(
- sidebar,
- "chrome://messenger/content/addressbook/abContactsPanel.xhtml?focus"
- );
-
- let abTree = sidebar.contentDocument.getElementById("abResultsTree");
- // The results are loaded async so wait for the population of the tree.
- utils.waitFor(
- () => abTree.view.rowCount > 0,
- "Addressbook cards didn't load"
- );
- click_tree_row(abTree, 0, cwc);
-
- sidebar.contentDocument.getElementById("ccButton").click();
-
- // The recipient is filled in, Send must be enabled.
- check_send_commands_state(cwc, true);
-
- cwc.window.toggleAddressPicker();
- close_compose_window(cwc);
-}
deleted file mode 100644
--- a/mail/test/mozmill/composition/test-send-format.js
+++ /dev/null
@@ -1,53 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests resulting send format of a message dependent on using HTML features
- * in the composition.
- */
-
-"use strict";
-
-var os = ChromeUtils.import("chrome://mozmill/content/stdlib/os.jsm");
-
-var { close_compose_window, open_compose_with_reply } = ChromeUtils.import(
- "resource://testing-common/mozmill/ComposeHelpers.jsm"
-);
-var { assert_equals, open_message_from_file } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { close_window } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-function checkMsgFile(aFilePath, aConvertibility) {
- let file = os.getFileForPath(
- os.abspath(aFilePath, os.getFileForPath(__file__))
- );
- let msgc = open_message_from_file(file);
-
- // Creating a reply should not affect convertibility.
- let cwc = open_compose_with_reply(msgc);
-
- assert_equals(cwc.window.DetermineConvertibility(), aConvertibility);
-
- close_compose_window(cwc);
- close_window(msgc);
-}
-
-/**
- * Tests that we only open one compose window for one instance of a draft.
- */
-function test_msg_convertibility() {
- checkMsgFile("./format1-plain.eml", Ci.nsIMsgCompConvertible.Plain);
-
- // Bug 1385636
- checkMsgFile("./format1-altering.eml", Ci.nsIMsgCompConvertible.Altering);
-
- // Bug 584313
- checkMsgFile("./format2-style-attr.eml", Ci.nsIMsgCompConvertible.No);
- checkMsgFile("./format3-style-tag.eml", Ci.nsIMsgCompConvertible.No);
-}
-
-function teardownModule() {}
deleted file mode 100644
--- a/mail/test/mozmill/composition/test-signature-init.js
+++ /dev/null
@@ -1,54 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests that the compose window initializes with the signature correctly
- * under various circumstances.
- */
-
-"use strict";
-
-var { get_compose_body, open_compose_new_mail } = ChromeUtils.import(
- "resource://testing-common/mozmill/ComposeHelpers.jsm"
-);
-var { assert_equals } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var kHtmlPref = "mail.identity.default.compose_html";
-var kReplyOnTopPref = "mail.identity.default.reply_on_top";
-var kReplyOnTop = 1;
-var kSigBottomPref = "mail.identity.default.sig_bottom";
-
-/**
- * Regression test for bug 762413 - tests that when we're set to reply above,
- * with the signature below the reply, we initialize the compose window such
- * that there is a <br> node above the signature. This allows the user to
- * insert text before the signature.
- */
-function test_on_reply_above_signature_below_reply() {
- let origHtml = Services.prefs.getBoolPref(kHtmlPref);
- let origReplyOnTop = Services.prefs.getIntPref(kReplyOnTopPref);
- let origSigBottom = Services.prefs.getBoolPref(kSigBottomPref);
-
- Services.prefs.setBoolPref(kHtmlPref, false);
- Services.prefs.setIntPref(kReplyOnTopPref, kReplyOnTop);
- Services.prefs.setBoolPref(kSigBottomPref, false);
-
- let cw = open_compose_new_mail();
- let mailBody = get_compose_body(cw);
-
- let node = mailBody.firstChild;
- assert_equals(
- node.localName,
- "br",
- "Expected a BR node to start the compose body."
- );
-
- Services.prefs.setBoolPref(kHtmlPref, origHtml);
- Services.prefs.setIntPref(kReplyOnTopPref, origReplyOnTop);
- Services.prefs.setBoolPref(kSigBottomPref, origSigBottom);
-}
deleted file mode 100644
--- a/mail/test/mozmill/composition/test-signature-updating.js
+++ /dev/null
@@ -1,263 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests that the signature updates properly when switching identities.
- */
-
-// mail.identity.id1.htmlSigFormat = false
-// mail.identity.id1.htmlSigText = "Tinderbox is soo 90ies"
-
-// mail.identity.id2.htmlSigFormat = true
-// mail.identity.id2.htmlSigText = "Tinderboxpushlog is the new <b>hotness!</b>"
-
-"use strict";
-
-var {
- close_compose_window,
- open_compose_new_mail,
- setup_msg_contents,
-} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
-var {
- assert_equals,
- be_in_folder,
- FAKE_SERVER_HOSTNAME,
- get_special_folder,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var cwc = null; // compose window controller
-
-function setupModule(module) {
- // Ensure we're in the tinderbox account as that has the right identities set
- // up for this test.
- let server = MailServices.accounts.FindServer(
- "tinderbox",
- FAKE_SERVER_HOSTNAME,
- "pop3"
- );
- let inbox = get_special_folder(Ci.nsMsgFolderFlags.Inbox, false, server);
- be_in_folder(inbox);
-}
-
-function teardownModule(module) {
- Services.prefs.clearUserPref("mail.compose.default_to_paragraph");
- Services.prefs.clearUserPref("mail.identity.id1.compose_html");
- Services.prefs.clearUserPref(
- "mail.identity.id1.suppress_signature_separator"
- );
- Services.prefs.clearUserPref(
- "mail.identity.id2.suppress_signature_separator"
- );
-}
-
-/**
- * Test that the plaintext compose window has a signature initially,
- * and has the correct signature after switching to another identity.
- */
-function plaintextComposeWindowSwitchSignatures(suppressSigSep) {
- Services.prefs.setBoolPref("mail.identity.id1.compose_html", false);
- Services.prefs.setBoolPref(
- "mail.identity.id1.suppress_signature_separator",
- suppressSigSep
- );
- Services.prefs.setBoolPref(
- "mail.identity.id2.suppress_signature_separator",
- suppressSigSep
- );
- cwc = open_compose_new_mail();
-
- let contentFrame = cwc.e("content-frame");
- let mailBody = contentFrame.contentDocument.body;
-
- // The first node in the body should be a BR node, which allows the user
- // to insert text before / outside of the signature.
- assert_equals(mailBody.firstChild.localName, "br");
-
- setup_msg_contents(cwc, "", "Plaintext compose window", "Body, first line.");
-
- let node = mailBody.lastChild;
-
- // The last node is a BR - this allows users to put text after the
- // signature without it being styled like the signature.
- assert_equals(node.localName, "br");
- node = node.previousSibling;
-
- // Now we should have the DIV node that contains the signature, with
- // the class moz-signature.
- assert_equals(node.localName, "div");
-
- const kSeparator = "-- ";
- const kSigClass = "moz-signature";
- assert_equals(node.className, kSigClass);
-
- let sigNode = node.firstChild;
-
- if (!suppressSigSep) {
- assert_equals(sigNode.textContent, kSeparator);
- let brNode = sigNode.nextSibling;
- assert_equals(brNode.localName, "br");
- sigNode = brNode.nextSibling;
- }
-
- let expectedText = "Tinderbox is soo 90ies";
- assert_equals(sigNode.textContent, expectedText);
-
- // Now switch identities!
- cwc.click(cwc.eid("msgIdentity"));
- cwc.click_menus_in_sequence(cwc.e("msgIdentityPopup"), [
- { identitykey: "id2" },
- ]);
-
- node = contentFrame.contentDocument.body.lastChild;
-
- // The last node is a BR - this allows users to put text after the
- // signature without it being styled like the signature.
- assert_equals(node.localName, "br");
- node = node.previousSibling;
-
- assert_equals(node.localName, "div");
- assert_equals(node.className, kSigClass);
-
- sigNode = node.firstChild;
-
- if (!suppressSigSep) {
- expectedText = "-- ";
- assert_equals(sigNode.textContent, kSeparator);
- let brNode = sigNode.nextSibling;
- assert_equals(brNode.localName, "br");
- sigNode = brNode.nextSibling;
- }
-
- expectedText = "Tinderboxpushlog is the new *hotness!*";
- assert_equals(sigNode.textContent, expectedText);
-
- // Now check that the original signature has been removed by ensuring
- // that there's only one node with class moz-signature.
- let sigs = contentFrame.contentDocument.querySelectorAll("." + kSigClass);
- assert_equals(sigs.length, 1);
-
- // And ensure that the text we wrote wasn't altered
- let bodyFirstChild = contentFrame.contentDocument.body.firstChild;
-
- while (node != bodyFirstChild) {
- node = node.previousSibling;
- }
-
- assert_equals(node.nodeValue, "Body, first line.");
-
- close_compose_window(cwc);
-}
-
-function testPlaintextComposeWindowSwitchSignatures() {
- plaintextComposeWindowSwitchSignatures(false);
-}
-
-function testPlaintextComposeWindowSwitchSignaturesWithSuppressedSeparator() {
- plaintextComposeWindowSwitchSignatures(true);
-}
-
-/**
- * Same test, but with an HTML compose window
- */
-function HTMLComposeWindowSwitchSignatures(suppressSigSep, paragraphFormat) {
- Services.prefs.setBoolPref(
- "mail.compose.default_to_paragraph",
- paragraphFormat
- );
-
- Services.prefs.setBoolPref("mail.identity.id1.compose_html", true);
- Services.prefs.setBoolPref(
- "mail.identity.id1.suppress_signature_separator",
- suppressSigSep
- );
- Services.prefs.setBoolPref(
- "mail.identity.id2.suppress_signature_separator",
- suppressSigSep
- );
- cwc = open_compose_new_mail();
-
- setup_msg_contents(cwc, "", "HTML compose window", "Body, first line.");
-
- let contentFrame = cwc.e("content-frame");
- let node = contentFrame.contentDocument.body.lastChild;
-
- // In html compose, the signature is inside the last node, which has a
- // class="moz-signature".
- assert_equals(node.className, "moz-signature");
- node = node.firstChild; // text node containing the signature divider
- if (suppressSigSep) {
- assert_equals(node.nodeValue, "Tinderbox is soo 90ies");
- } else {
- assert_equals(node.nodeValue, "-- \nTinderbox is soo 90ies");
- }
-
- // Now switch identities!
- cwc.click(cwc.eid("msgIdentity"));
- cwc.click_menus_in_sequence(cwc.e("msgIdentityPopup"), [
- { identitykey: "id2" },
- ]);
-
- node = contentFrame.contentDocument.body.lastChild;
-
- // In html compose, the signature is inside the last node
- // with class="moz-signature".
- assert_equals(node.className, "moz-signature");
- node = node.firstChild; // text node containing the signature divider
- if (!suppressSigSep) {
- assert_equals(node.nodeValue, "-- ");
- node = node.nextSibling;
- assert_equals(node.localName, "br");
- node = node.nextSibling;
- }
- assert_equals(node.nodeValue, "Tinderboxpushlog is the new ");
- node = node.nextSibling;
- assert_equals(node.localName, "b");
- node = node.firstChild;
- assert_equals(node.nodeValue, "hotness!");
-
- // Now check that the original signature has been removed,
- // and no blank lines got added!
- node = contentFrame.contentDocument.body.firstChild;
- let textNode;
- if (paragraphFormat) {
- textNode = node.firstChild;
- } else {
- textNode = node;
- }
- assert_equals(textNode.nodeValue, "Body, first line.");
- if (!paragraphFormat) {
- node = node.nextSibling;
- assert_equals(node.localName, "br");
- }
- node = node.nextSibling;
- // check that the signature is immediately after the message text.
- assert_equals(node.className, "moz-signature");
- // check that that the signature is the last node.
- assert_equals(node, contentFrame.contentDocument.body.lastChild);
-
- close_compose_window(cwc);
-}
-
-function testHTMLComposeWindowSwitchSignatures() {
- HTMLComposeWindowSwitchSignatures(false, false);
-}
-
-function testHTMLComposeWindowSwitchSignaturesWithSuppressedSeparator() {
- HTMLComposeWindowSwitchSignatures(true, false);
-}
-
-function testHTMLComposeWindowSwitchSignaturesParagraphFormat() {
- HTMLComposeWindowSwitchSignatures(false, true);
-}
-
-function testHTMLComposeWindowSwitchSignaturesWithSuppressedSeparatorParagraphFormat() {
- HTMLComposeWindowSwitchSignatures(true, true);
-}
deleted file mode 100644
--- a/mail/test/mozmill/composition/testmsg.eml
+++ /dev/null
@@ -1,16 +0,0 @@
-Return-Path: <homer@example.com>
-Received: from smtp.example.com (smtpu [10.0.0.52])
- by storage (Cyrus v2.3.7-Invoca-RPM-2.3.7-1.1) with LMTPA;
- Mon, 26 Dec 2011 20:49:16 +0200
-Message-ID: <4EF8C1A5.1060708@example.com>
-Date: Mon, 26 Dec 2011 20:49:09 +0200
-From: Homer <homer@example.com>
-MIME-Version: 1.0
-To: Marge <marge@example.com>
-Subject: why
-Content-Type: text/plain; charset=UTF-8; format=flowed
-Content-Transfer-Encoding: 7bit
-
-Because they're stupid, that's why. That's why everybody does everything!
-
- -Homer
deleted file mode 100644
--- a/mail/test/mozmill/content-policy/html/mailtolink.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<html>
- <head>
- <title>Mailto Link Test</title>
- </head>
- <body bgcolor="#FFFFFF">
- <a href="mailto:nobody@mozilla.invalid" id="mailtolink">mailtolink</a>
- </body>
-</html>
deleted file mode 100644
index 4b0d444cf6c569c140f05f3051ee917379a8441a..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
--- a/mail/test/mozmill/content-policy/html/plugin.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<html>
- <head>
- <title>Plugin Test</title>
- </head>
- <body bgcolor="#FFFFFF">
- <embed id="testelement" type="application/x-test"
- style="width:400px; height:400px; margin-top:20px;" border="1">
- </embed>
- </body>
-</html>
deleted file mode 100644
--- a/mail/test/mozmill/content-policy/html/remote-noscript.html
+++ /dev/null
@@ -1,18 +0,0 @@
-<html>
- <head>
- <title>noscript test</title>
- </head>
- <body bgcolor="#FFFFFF">
- <h1>remote-noscript.html</h1>
- <p>This content is served over http!</p>
- <noscript>
- JavaScript is OFF!
- </noscript>
-
- <div id="scripted"> </scripted>
- <script>
- var jsIsTurnedOn = true; // variable to check in test
- document.getElementById("scripted").innerHTML = "JavaScript is ON!";
- </script>
- </body>
-</html>
deleted file mode 100644
--- a/mail/test/mozmill/content-policy/html/remoteimage.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<html>
- <head>
- <title>Remote Image Test</title>
- </head>
- <body bgcolor="#FFFFFF">
- <img id="testelement" src="pass.png"/>
- </body>
-</html>
deleted file mode 100644
--- a/mail/test/mozmill/content-policy/html/remoteimagedata.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<html>
- <head>
- <title>Remote Image Test</title>
- </head>
- <body bgcolor="#FFFFFF">
- <img id="testelement" src="data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%002%00%00%00%14%08%02%00%00%00%40%A8%F9%CD%00%00%02%A3IDATH%C7%ED%96%3D%2C%2CQ%14%C7%FF3K%22H4%3Ev%13%1F%DDR%10QP%09BT%22%0A%C2F%23HhD%B2%09%A5NB%88%C4%2B%25%0A%0At%14%14%04%85%CFD%82H%14%3E%12%8A-h%84B%7Cd%AD%FD%BDb%5E%26c%F7%3D%3B%5E%A5pr%8A%B9%E7%FE%EE%B9%FF%DCs%EE%CC%18%80%BE%9F%99%FA%96%F6%23%EB%3Fd%15%A9%C8%90%E1%F4d%25g%2B%BBNu%EBZ%8FYs%AB%5B%8F%3C%86%8C%90B%F1%19%8Fu%1CP%20W%B9%C9JNRR%8Er*U%19T0%AC%B0%7B%C6%B0Z%BEHE%17%BA%18%D7%B8%24DD%91%7B%DD%1F%E8%60G%3B%A6%CC-mU%AA%D2N%3A%A9%C9%A0%82%92%C646%A8A%A7%A6%3D%ED%D5%AA%D6%23O%9B%DA%FC%F2G%14%09)t%A0%83S%9D%3E%EA1%5D%E9.%19%01%40!%85%E2%CF%B3%D3%26%98%10j%A5%D5%19%2C%A7%DC%83G%A8%8C%B2%18%BE%91F%A1%0D6b%E2W%5C%BD%F1%E6%9EI%20%EB%81%07%A1%12J%EC%C8%25%97B%DDt%7B%F1%0A%9Ds%EE%E4%8B)%16z%E5%95%7F%9B%1B%26A%CB%A7*U%92%E9%B8%19%F3%9A%97%14P%A0E-%92%16%B4%E0%E4%F3%95%2FiF3%9F%E4t%C3%248%AD%13N%9CE%8C%12%F5%E3%CF%24%F3%8D%B7m%B6%85%FC%F8%A3Dm~%8B-%AB%BE%0D4%2C%B1%F4%CCs%7CN7%CCg%B2%DEyo%A6Yh%99e%2Br%C8%A1P%0F%3D%D6%AC%0F%9F%D0%11G%CEUk%AC%15P%20%24%94FZ%3B%ED%FB%EC%C7dN%C8%7C%90u%C6%99%E5\'%9C%2C%B0PM%B5P%1F%7D%F6y%04%09%0A%AD%B3n%0D%FB%E9%17%1Ad0f%D70%E1%25%96%02%04%D2I%B7%F6%EE%A2%2BL%D8%3D%F3A%96%ED%26%A6%0F_%13M%2B%AC%D8%9A%22D%7C%F8%AC%0AZ%91%5Dv%85%F2%C8%7B%E7%FD%AF%9D%FB%C4%D34%D3%D6%E5%18a%C4%3D%93%A0%B7%9C%B6%C9%A6S%BA%D3w%D8%F9d%E1%11GB%15T%B8g%BE%F0%F1%99%D3%9C!cO%7Bg%3A%B3%7DHC%F1%F71%C6JT%22%E9U%AF_%60%5C%9E%D6%0B%2F%19d%D4P%13%13%BF%E1%C6%C4%CC%22%CB%AA%EC%2F~%5Dq%15%C3%AC%B0b%BD%EA%AC%A1%1B%C6%AD%ACE%16%85%A6%98%8A%9F%AA%A7%5Eh%95U%3BO)%A5%BD%F4%0E3%3C%CAh\'%9D)%A4d%91u%CD%B5s%AF%CF%19%B7%B2ZhI%22%E9%8E%BB%F8%A9Yf%85%3A%E8%006%D8%18%60%A0%8A*%2F%5E%0F%1E%133%9F%FC%5EzC%84l%DE%0Dc%FC%FC%9D~%C1~%03%97%96%03%F2QP%E0%18%00%00%00%00IEND%AEB%60%82"/>"/>
- </body>
-</html>
deleted file mode 100644
--- a/mail/test/mozmill/content-policy/html/remotevideo.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<html>
- <head>
- <title>Remote Image Test</title>
- </head>
- <body bgcolor="#FFFFFF">
- <video id="testelement" src="video.ogv"/>
- </body>
-</html>
deleted file mode 100644
index 61c179447f8a146a7202db9fe6ab96ac3d92e288..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
--- a/mail/test/mozmill/content-policy/test-compose-mailto.js
+++ /dev/null
@@ -1,99 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-var composeHelper = ChromeUtils.import(
- "resource://testing-common/mozmill/ComposeHelpers.jsm"
-);
-var { content_tab_eid, open_content_tab_with_url } = ChromeUtils.import(
- "resource://testing-common/mozmill/ContentTabHelpers.jsm"
-);
-var { mc } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { input_value } = ChromeUtils.import(
- "resource://testing-common/mozmill/KeyboardHelpers.jsm"
-);
-var {
- plan_for_modal_dialog,
- wait_for_modal_dialog,
- wait_for_window_close,
-} = ChromeUtils.import("resource://testing-common/mozmill/WindowHelpers.jsm");
-
-var folder = null;
-var gMsgNo = 0;
-var gComposeWin;
-var gNewTab;
-var gPreCount;
-
-// RELATIVE_ROOT messes with the collector, so we have to bring the path back
-// so we get the right path for the resources.
-var url = collector.addHttpResource("../content-policy/html", "content");
-
-function test_openComposeFromMailToLink() {
- // Open a content tab with the mailto link in it.
- // To open a tab we're going to have to cheat and use tabmail so we can load
- // in the data of what we want.
- gPreCount = mc.tabmail.tabContainer.allTabs.length;
- gNewTab = open_content_tab_with_url(url + "mailtolink.html");
- gComposeWin = composeHelper.open_compose_with_element_click(
- content_tab_eid(gNewTab, "mailtolink")
- );
-}
-
-function test_checkInsertImage() {
- // First focus on the editor element
- gComposeWin.e("content-frame").focus();
-
- // Now open the image window
- plan_for_modal_dialog("Mail:image", function insert_image(mwc) {
- // Insert the url of the image.
- let srcloc = mwc.window.document.getElementById("srcInput");
- srcloc.focus();
-
- input_value(mwc, url + "pass.png");
- mwc.sleep(0);
-
- // Don't add alternate text
- mwc.click(mwc.eid("noAltTextRadio"));
-
- // Accept the dialog
- mwc.window.document.querySelector("dialog").acceptDialog();
- });
- gComposeWin.click(gComposeWin.eid("insertImage"));
-
- wait_for_modal_dialog();
- wait_for_window_close();
-
- // gComposeWin.sleep(500);
-
- // Test that the image load has not been denied
- let childImages = gComposeWin
- .e("content-frame")
- .contentDocument.getElementsByTagName("img");
-
- if (childImages.length != 1) {
- throw new Error(
- "Expecting one image in document, actually have " + childImages.length
- );
- }
-
- // Should be the only image, so just check the first.
- if (childImages[0].imageBlockingStatus != Ci.nsIContentPolicy.ACCEPT) {
- throw new Error(
- "Loading of image has been unexpectedly blocked in a mailto compose window"
- );
- }
-}
-
-function test_closeComposeWindowAndTab() {
- composeHelper.close_compose_window(gComposeWin);
-
- mc.tabmail.closeTab(gNewTab);
-
- if (mc.tabmail.tabContainer.allTabs.length != gPreCount) {
- throw new Error("The content tab didn't close");
- }
-}
deleted file mode 100644
--- a/mail/test/mozmill/content-policy/test-dns-prefetch.js
+++ /dev/null
@@ -1,202 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * The purpose of this test is to ensure that dns prefetch is turned off in
- * the message pane and compose windows. It also checks that dns prefetch is
- * currently turned off in content tabs, although when bug 545407 is fixed, it
- * should be turned back on again.
- */
-
-"use strict";
-
-var composeHelper = ChromeUtils.import(
- "resource://testing-common/mozmill/ComposeHelpers.jsm"
-);
-var { open_content_tab_with_url } = ChromeUtils.import(
- "resource://testing-common/mozmill/ContentTabHelpers.jsm"
-);
-var {
- assert_nothing_selected,
- assert_selected_and_displayed,
- be_in_folder,
- close_message_window,
- create_folder,
- mc,
- open_selected_message_in_new_window,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var folder = null;
-var gMsgNo = 0;
-var gMsgHdr = null;
-
-// These two constants are used to build the message body.
-var msgBody =
- '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\n' +
- "<html>\n" +
- "<head>\n" +
- "\n" +
- '<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">\n' +
- "</head>\n" +
- '<body bgcolor="#ffffff" text="#000000">\n' +
- "dns prefetch test message\n" +
- "</body>\n</html>\n";
-
-function setupModule(module) {
- folder = create_folder("dnsPrefetch");
-}
-
-function addToFolder(aSubject, aBody, aFolder) {
- let msgId =
- Cc["@mozilla.org/uuid-generator;1"]
- .getService(Ci.nsIUUIDGenerator)
- .generateUUID() + "@mozillamessaging.invalid";
-
- let source =
- "From - Sat Nov 1 12:39:54 2008\n" +
- "X-Mozilla-Status: 0001\n" +
- "X-Mozilla-Status2: 00000000\n" +
- "Message-ID: <" +
- msgId +
- ">\n" +
- "Date: Wed, 11 Jun 2008 20:32:02 -0400\n" +
- "From: Tester <tests@mozillamessaging.invalid>\n" +
- "User-Agent: Thunderbird 3.0a2pre (Macintosh/2008052122)\n" +
- "MIME-Version: 1.0\n" +
- "To: recipient@mozillamessaging.invalid\n" +
- "Subject: " +
- aSubject +
- "\n" +
- "Content-Type: text/html; charset=ISO-8859-1\n" +
- "Content-Transfer-Encoding: 7bit\n" +
- "\n" +
- aBody +
- "\n";
-
- aFolder.QueryInterface(Ci.nsIMsgLocalMailFolder);
- aFolder.gettingNewMessages = true;
-
- aFolder.addMessage(source);
- aFolder.gettingNewMessages = false;
-
- return aFolder.msgDatabase.getMsgHdrForMessageID(msgId);
-}
-
-function addMsgToFolder(folder) {
- let msgDbHdr = addToFolder("exposed test message " + gMsgNo, msgBody, folder);
-
- // select the newly created message
- gMsgHdr = select_click_row(gMsgNo);
-
- if (msgDbHdr != gMsgHdr) {
- throw new Error(
- "Selected Message Header is not the same as generated header"
- );
- }
-
- assert_selected_and_displayed(gMsgNo);
-
- ++gMsgNo;
-}
-
-/**
- * Check remote content in a compose window.
- *
- * @param test The test from TESTS that is being performed.
- * @param replyType The type of the compose window, 0 = normal compose,
- * 1 = reply, 2 = forward.
- * @param loadAllowed Whether or not the load is expected to be allowed.
- */
-function checkComposeWindow(replyType) {
- let errMsg = "";
- let replyWindow = null;
- switch (replyType) {
- case 0:
- replyWindow = composeHelper.open_compose_new_mail();
- errMsg = "new mail";
- break;
- case 1:
- replyWindow = composeHelper.open_compose_with_reply();
- errMsg = "reply";
- break;
- case 2:
- replyWindow = composeHelper.open_compose_with_forward();
- errMsg = "forward";
- break;
- }
-
- // Check the prefetch in the compose window.
- if (replyWindow.e("content-frame").docShell.allowDNSPrefetch) {
- throw new Error(
- "DNS Prefetch on compose window is not disabled (" + errMsg + ")"
- );
- }
-
- composeHelper.close_compose_window(replyWindow);
-}
-
-function test_dnsPrefetch_message() {
- // Now we have started up, simply check that DNS prefetch is disabled
- if (mc.e("messagepane").docShell.allowDNSPrefetch) {
- throw new Error("DNS Prefetch on messagepane is not disabled at startup");
- }
-
- be_in_folder(folder);
-
- assert_nothing_selected();
-
- addMsgToFolder(folder);
-
- // Now we've got a message selected, check again.
- if (mc.e("messagepane").docShell.allowDNSPrefetch) {
- throw new Error(
- "DNS Prefetch on messagepane is not disabled after selecting message"
- );
- }
-}
-
-function test_dnsPrefetch_standaloneMessage() {
- let msgc = open_selected_message_in_new_window();
- assert_selected_and_displayed(msgc, gMsgHdr);
-
- // Check the docshell.
- if (mc.e("messagepane").docShell.allowDNSPrefetch) {
- throw new Error(
- "DNS Prefetch on messagepane is not disabled in standalone message window."
- );
- }
-
- close_message_window(msgc);
-}
-
-function test_dnsPrefetch_compose() {
- checkComposeWindow(0);
- checkComposeWindow(1);
- checkComposeWindow(2);
-}
-
-function test_dnsPrefetch_contentTab() {
- // To open a tab we're going to have to cheat and use tabmail so we can load
- // in the data of what we want.
- let preCount = mc.tabmail.tabContainer.allTabs.length;
-
- let dataurl =
- "data:text/html,<html><head><title>test dns prefetch</title>" +
- "</head><body>test dns prefetch</body></html>";
-
- let newTab = open_content_tab_with_url(dataurl);
-
- if (!mc.tabmail.getBrowserForSelectedTab().docShell.allowDNSPrefetch) {
- throw new Error("DNS prefetch unexpectedly disabled in content tabs");
- }
-
- mc.tabmail.closeTab(newTab);
-
- if (mc.tabmail.tabContainer.allTabs.length != preCount) {
- throw new Error("The content tab didn't close");
- }
-}
deleted file mode 100644
--- a/mail/test/mozmill/content-policy/test-exposed-in-content-tabs.js
+++ /dev/null
@@ -1,160 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * The purpose of this test is to ensure that remote content can't gain access
- * to messages by loading their URIs.
- */
-
-"use strict";
-
-var composeHelper = ChromeUtils.import(
- "resource://testing-common/mozmill/ComposeHelpers.jsm"
-);
-var { open_content_tab_with_url } = ChromeUtils.import(
- "resource://testing-common/mozmill/ContentTabHelpers.jsm"
-);
-var {
- assert_nothing_selected,
- assert_selected_and_displayed,
- be_in_folder,
- create_folder,
- mc,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var folder = null;
-var gMsgNo = 0;
-
-// RELATIVE_ROOT messes with the collector, so we have to bring the path back
-// so we get the right path for the resources.
-var url = collector.addHttpResource("../content-policy/html", "content");
-
-// These two constants are used to build the message body.
-var msgBody =
- '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\n' +
- "<html>\n" +
- "<head>\n" +
- "\n" +
- '<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">\n' +
- "</head>\n" +
- '<body bgcolor="#ffffff" text="#000000">\n' +
- '<img id="testelement" src="' +
- url +
- 'pass.png"/>\n' +
- "</body>\n</html>\n";
-
-function setupModule(module) {
- folder = create_folder("exposedInContent");
-}
-
-function addToFolder(aSubject, aBody, aFolder) {
- let msgId =
- Cc["@mozilla.org/uuid-generator;1"]
- .getService(Ci.nsIUUIDGenerator)
- .generateUUID() + "@mozillamessaging.invalid";
-
- let source =
- "From - Sat Nov 1 12:39:54 2008\n" +
- "X-Mozilla-Status: 0001\n" +
- "X-Mozilla-Status2: 00000000\n" +
- "Message-ID: <" +
- msgId +
- ">\n" +
- "Date: Wed, 11 Jun 2008 20:32:02 -0400\n" +
- "From: Tester <tests@mozillamessaging.invalid>\n" +
- "User-Agent: Thunderbird 3.0a2pre (Macintosh/2008052122)\n" +
- "MIME-Version: 1.0\n" +
- "To: recipient@mozillamessaging.invalid\n" +
- "Subject: " +
- aSubject +
- "\n" +
- "Content-Type: text/html; charset=ISO-8859-1\n" +
- "Content-Transfer-Encoding: 7bit\n" +
- "\n" +
- aBody +
- "\n";
-
- aFolder.QueryInterface(Ci.nsIMsgLocalMailFolder);
- aFolder.gettingNewMessages = true;
-
- aFolder.addMessage(source);
- aFolder.gettingNewMessages = false;
-
- return aFolder.msgDatabase.getMsgHdrForMessageID(msgId);
-}
-
-function addMsgToFolder(folder) {
- let msgDbHdr = addToFolder("exposed test message " + gMsgNo, msgBody, folder);
-
- // select the newly created message
- let msgHdr = select_click_row(gMsgNo);
-
- if (msgDbHdr != msgHdr) {
- throw new Error(
- "Selected Message Header is not the same as generated header"
- );
- }
-
- assert_selected_and_displayed(gMsgNo);
-
- ++gMsgNo;
-
- // We also want to return the url of the message, so save that here.
- let msgSimpleURL = msgHdr.folder.getUriForMsg(msgHdr);
-
- let msgService = Cc["@mozilla.org/messenger;1"]
- .createInstance(Ci.nsIMessenger)
- .messageServiceFromURI(msgSimpleURL);
-
- var neckoURL = {};
- msgService.GetUrlForUri(msgSimpleURL, neckoURL, null);
-
- // This is the full url to the message that we want (i.e. passing this to
- // a browser element or iframe will display it).
- return neckoURL.value.spec;
-}
-
-function checkContentTab(msgURL) {
- // To open a tab we're going to have to cheat and use tabmail so we can load
- // in the data of what we want.
- let preCount = mc.tabmail.tabContainer.allTabs.length;
-
- let dataurl =
- "data:text/html,<html><head><title>test exposed</title>" +
- '</head><body><iframe id="msgIframe" src="' +
- msgURL +
- '"/></body></html>';
-
- let newTab = open_content_tab_with_url(dataurl);
-
- if (
- mc.window.content.document.getElementById("msgIframe").contentDocument
- .URL != "about:blank"
- ) {
- throw new Error(
- "Message display/access has not been blocked from remote content!"
- );
- }
-
- mc.tabmail.closeTab(newTab);
-
- if (mc.tabmail.tabContainer.allTabs.length != preCount) {
- throw new Error("The content tab didn't close");
- }
-}
-
-function test_exposedInContentTabs() {
- be_in_folder(folder);
-
- assert_nothing_selected();
-
- // Check for denied in mail
- let msgURL = addMsgToFolder(folder);
-
- // Check allowed in content tab
- checkContentTab(msgURL);
-}
deleted file mode 100644
--- a/mail/test/mozmill/content-policy/test-general-content-policy.js
+++ /dev/null
@@ -1,714 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Checks various remote content policy workings, including:
- *
- * - Images
- * - Video
- *
- * In:
- *
- * - Messages
- * - Reply email compose window
- * - Forward email compose window
- * - Content tab
- * - Feed message
- */
-
-"use strict";
-
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-var os = ChromeUtils.import("chrome://mozmill/content/stdlib/os.jsm");
-
-var {
- close_compose_window,
- open_compose_with_forward,
- open_compose_with_reply,
-} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
-var { open_content_tab_with_url } = ChromeUtils.import(
- "resource://testing-common/mozmill/ContentTabHelpers.jsm"
-);
-var {
- assert_equals,
- assert_nothing_selected,
- assert_selected_and_displayed,
- be_in_folder,
- close_message_window,
- create_folder,
- mc,
- open_message_from_file,
- open_selected_message,
- plan_for_message_display,
- select_click_row,
- set_open_message_behavior,
- wait_for_message_display_completion,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { input_value } = ChromeUtils.import(
- "resource://testing-common/mozmill/KeyboardHelpers.jsm"
-);
-var {
- get_notification_button,
- wait_for_notification_to_show,
- wait_for_notification_to_stop,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/NotificationBoxHelpers.jsm"
-);
-var {
- plan_for_modal_dialog,
- plan_for_new_window,
- wait_for_modal_dialog,
- wait_for_new_window,
- wait_for_window_close,
-} = ChromeUtils.import("resource://testing-common/mozmill/WindowHelpers.jsm");
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-var folder = null;
-var gMsgNo = 0;
-
-// RELATIVE_ROOT messes with the collector, so we have to bring the path back
-// so we get the right path for the resources.
-var url = collector.addHttpResource("../content-policy/html", "content");
-
-/**
- * The TESTS array is constructed from objects containing the following:
- *
- * type: The type of the test being run.
- * body: The html to be inserted into the body of the message under
- * test. Note: the element under test for content
- * allowed/disallowed should have id 'testelement'.
- * webPage: The web page to load during the content tab part of the
- * test.
- * checkForAllowed: A function that is passed the element with id 'testelement'
- * to check for remote content being allowed/disallowed.
- * This function should return true if remote content was
- * allowed, false otherwise.
- */
-var TESTS = [
- {
- type: "Image",
- checkDenied: true,
- body: '<img id="testelement" src="' + url + 'pass.png"/>\n',
- webPage: "remoteimage.html",
- checkForAllowed: function img_checkAllowed(element) {
- return element.imageBlockingStatus == Ci.nsIContentPolicy.ACCEPT;
- },
- },
- {
- type: "Video",
- checkDenied: true,
- body: '<video id="testelement" src="' + url + 'video.ogv"/>\n',
- webPage: "remotevideo.html",
- checkForAllowed: function video_checkAllowed(element) {
- return element.networkState != element.NETWORK_NO_SOURCE;
- },
- },
- {
- type: "Image-Data",
- checkDenied: false,
- body:
- '<img id="testelement" src="data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%002%00%00%00%14%08%02%00%00%00%40%A8%F9%CD%00%00%02%A3IDATH%C7%ED%96%3D%2C%2CQ%14%C7%FF3K%22H4%3Ev%13%1F%DDR%10QP%09BT%22%0A%C2F%23HhD%B2%09%A5NB%88%C4%2B%25%0A%0At%14%14%04%85%CFD%82H%14%3E%12%8A-h%84B%7Cd%AD%FD%BDb%5E%26c%F7%3D%3B%5E%A5pr%8A%B9%E7%FE%EE%B9%FF%DCs%EE%CC%18%80%BE%9F%99%FA%96%F6%23%EB%3Fd%15%A9%C8%90%E1%F4d%25g%2B%BBNu%EBZ%8FYs%AB%5B%8F%3C%86%8C%90B%F1%19%8Fu%1CP%20W%B9%C9JNRR%8Er*U%19T0%AC%B0%7B%C6%B0Z%BEHE%17%BA%18%D7%B8%24DD%91%7B%DD%1F%E8%60G%3B%A6%CC-mU%AA%D2N%3A%A9%C9%A0%82%92%C646%A8A%A7%A6%3D%ED%D5%AA%D6%23O%9B%DA%FC%F2G%14%09)t%A0%83S%9D%3E%EA1%5D%E9.%19%01%40!%85%E2%CF%B3%D3%26%98%10j%A5%D5%19%2C%A7%DC%83G%A8%8C%B2%18%BE%91F%A1%0D6b%E2W%5C%BD%F1%E6%9EI%20%EB%81%07%A1%12J%EC%C8%25%97B%DDt%7B%F1%0A%9Ds%EE%E4%8B)%16z%E5%95%7F%9B%1B%26A%CB%A7*U%92%E9%B8%19%F3%9A%97%14P%A0E-%92%16%B4%E0%E4%F3%95%2FiF3%9F%E4t%C3%248%AD%13N%9CE%8C%12%F5%E3%CF%24%F3%8D%B7m%B6%85%FC%F8%A3Dm~%8B-%AB%BE%0D4%2C%B1%F4%CCs%7CN7%CCg%B2%DEyo%A6Yh%99e%2Br%C8%A1P%0F%3D%D6%AC%0F%9F%D0%11G%CEUk%AC%15P%20%24%94FZ%3B%ED%FB%EC%C7dN%C8%7C%90u%C6%99%E5\'%9C%2C%B0PM%B5P%1F%7D%F6y%04%09%0A%AD%B3n%0D%FB%E9%17%1Ad0f%D70%E1%25%96%02%04%D2I%B7%F6%EE%A2%2BL%D8%3D%F3A%96%ED%26%A6%0F_%13M%2B%AC%D8%9A%22D%7C%F8%AC%0AZ%91%5Dv%85%F2%C8%7B%E7%FD%AF%9D%FB%C4%D34%D3%D6%E5%18a%C4%3D%93%A0%B7%9C%B6%C9%A6S%BA%D3w%D8%F9d%E1%11GB%15T%B8g%BE%F0%F1%99%D3%9C!cO%7Bg%3A%B3%7DHC%F1%F71%C6JT%22%E9U%AF_%60%5C%9E%D6%0B%2F%19d%D4P%13%13%BF%E1%C6%C4%CC%22%CB%AA%EC%2F~%5Dq%15%C3%AC%B0b%BD%EA%AC%A1%1B%C6%AD%ACE%16%85%A6%98%8A%9F%AA%A7%5Eh%95U%3BO)%A5%BD%F4%0E3%3C%CAh\'%9D)%A4d%91u%CD%B5s%AF%CF%19%B7%B2ZhI%22%E9%8E%BB%F8%A9Yf%85%3A%E8%006%D8%18%60%A0%8A*%2F%5E%0F%1E%133%9F%FC%5EzC%84l%DE%0Dc%FC%FC%9D~%C1~%03%97%96%03%F2QP%E0%18%00%00%00%00IEND%AEB%60%82"/>\n',
- webPage: "remoteimagedata.html",
- checkForAllowed: function img_checkAllowed(element) {
- return element.imageBlockingStatus == Ci.nsIContentPolicy.ACCEPT;
- },
- },
-];
-
-// These two constants are used to build the message body.
-var msgBodyStart =
- '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\n' +
- "<html>\n" +
- "<head>\n" +
- "\n" +
- '<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">\n' +
- "</head>\n" +
- '<body bgcolor="#ffffff" text="#000000">\n';
-
-var msgBodyEnd = "</body>\n</html>\n";
-
-function setupModule(module) {
- folder = create_folder("generalContentPolicy");
-}
-
-// We can't call it test since that it would be run as subtest.
-function checkPermission(aURI) {
- let principal = Services.scriptSecurityManager.createContentPrincipal(
- aURI,
- {}
- );
- return Services.perms.testPermissionFromPrincipal(principal, "image");
-}
-
-function addPermission(aURI, aAllowDeny) {
- let principal = Services.scriptSecurityManager.createContentPrincipal(
- aURI,
- {}
- );
- return Services.perms.addFromPrincipal(principal, "image", aAllowDeny);
-}
-
-function removePermission(aURI) {
- let principal = Services.scriptSecurityManager.createContentPrincipal(
- aURI,
- {}
- );
- return Services.perms.removeFromPrincipal(principal, "image");
-}
-
-function addToFolder(aSubject, aBody, aFolder) {
- let msgId =
- Cc["@mozilla.org/uuid-generator;1"]
- .getService(Ci.nsIUUIDGenerator)
- .generateUUID() + "@mozillamessaging.invalid";
-
- let source =
- "From - Sat Nov 1 12:39:54 2008\n" +
- "X-Mozilla-Status: 0001\n" +
- "X-Mozilla-Status2: 00000000\n" +
- "Message-ID: <" +
- msgId +
- ">\n" +
- "Date: Wed, 11 Jun 2008 20:32:02 -0400\n" +
- "From: Tester <tests@mozillamessaging.invalid>\n" +
- "User-Agent: Thunderbird 3.0a2pre (Macintosh/2008052122)\n" +
- "MIME-Version: 1.0\n" +
- "To: recipient@mozillamessaging.invalid\n" +
- "Subject: " +
- aSubject +
- "\n" +
- "Content-Type: text/html; charset=ISO-8859-1\n" +
- "Content-Transfer-Encoding: 7bit\n" +
- "\n" +
- aBody +
- "\n";
-
- aFolder.QueryInterface(Ci.nsIMsgLocalMailFolder);
- aFolder.gettingNewMessages = true;
-
- aFolder.addMessage(source);
- aFolder.gettingNewMessages = false;
-
- return aFolder.msgDatabase.getMsgHdrForMessageID(msgId);
-}
-
-function addMsgToFolderAndCheckContent(folder, test) {
- let msgDbHdr = addToFolder(
- test.type + " test message " + gMsgNo,
- msgBodyStart + test.body + msgBodyEnd,
- folder
- );
-
- // select the newly created message
- let msgHdr = select_click_row(gMsgNo);
-
- if (msgDbHdr != msgHdr) {
- throw new Error(
- "Selected Message Header is not the same as generated header"
- );
- }
-
- assert_selected_and_displayed(gMsgNo);
-
- // Now check that the content hasn't been loaded
- if (test.checkDenied) {
- if (
- test.checkForAllowed(
- mc.window.content.document.getElementById("testelement")
- )
- ) {
- throw new Error(
- test.type + " has not been blocked in message content as expected."
- );
- }
- } else if (
- !test.checkForAllowed(
- mc.window.content.document.getElementById("testelement")
- )
- ) {
- throw new Error(
- test.type + " has been unexpectedly blocked in message content."
- );
- }
-
- ++gMsgNo;
-}
-
-/**
- * Check remote content in a compose window.
- *
- * @param test The test from TESTS that is being performed.
- * @param replyType The type of the compose window, set to true for "reply",
- * false for "forward".
- * @param loadAllowed Whether or not the load is expected to be allowed.
- */
-function checkComposeWindow(test, replyType, loadAllowed) {
- let replyWindow = replyType
- ? open_compose_with_reply()
- : open_compose_with_forward();
-
- if (
- test.checkForAllowed(
- replyWindow.window.document
- .getElementById("content-frame")
- .contentDocument.getElementById("testelement")
- ) != loadAllowed
- ) {
- throw new Error(
- test.type +
- " has not been " +
- (loadAllowed ? "allowed" : "blocked") +
- " in reply window as expected."
- );
- }
-
- close_compose_window(replyWindow);
-}
-
-/**
- * Check remote content in stand-alone message window, and reload
- */
-function checkStandaloneMessageWindow(test, loadAllowed) {
- plan_for_new_window("mail:messageWindow");
- // Open it
- set_open_message_behavior("NEW_WINDOW");
- open_selected_message();
- let msgc = wait_for_new_window("mail:messageWindow");
- wait_for_message_display_completion(msgc, true);
- if (
- test.checkForAllowed(
- msgc.window.content.document.getElementById("testelement")
- ) != loadAllowed
- ) {
- throw new Error(
- test.type + " has not been blocked in message content as expected."
- );
- }
-
- // Clean up, close the window
- close_message_window(msgc);
-}
-
-/**
- * Check remote content in stand-alone message window loaded from .eml file.
- * Make sure there's a notification bar.
- */
-function checkEMLMessageWindow(test, emlFile) {
- let msgc = open_message_from_file(emlFile);
- if (!msgc.e("mail-notification-top")) {
- throw new Error(test.type + " has no content notification bar.");
- }
- if (msgc.e("mail-notification-top").collapsed) {
- throw new Error(test.type + " content notification bar not shown.");
- }
-
- // Clean up, close the window
- close_message_window(msgc);
-}
-
-/**
- * Helper method to save one of the test files as an .eml file.
- * @return the file the message was safed to
- */
-function saveAsEMLFile(msgNo) {
- let msgHdr = select_click_row(msgNo);
- let messenger = Cc["@mozilla.org/messenger;1"].createInstance(
- Ci.nsIMessenger
- );
- let profD = Services.dirsvc.get("ProfD", Ci.nsIFile);
- let file = os.getFileForPath(
- os.abspath("./content-policy-test-" + msgNo + ".eml", profD)
- );
- messenger.saveAs(
- msgHdr.folder.getUriForMsg(msgHdr),
- true,
- null,
- file.path,
- true
- );
- // no listener for saveAs, though we should add one.
- mc.sleep(5000);
- return file;
-}
-
-function allowRemoteContentAndCheck(test) {
- addMsgToFolderAndCheckContent(folder, test);
-
- plan_for_message_display(mc);
-
- // Click on the allow remote content button
- const kBoxId = "mail-notification-top";
- const kNotificationValue = "remoteContent";
- wait_for_notification_to_show(mc, kBoxId, kNotificationValue);
- let prefButton = get_notification_button(mc, kBoxId, kNotificationValue, {
- popup: "remoteContentOptions",
- });
- mc.click(new elib.Elem(prefButton));
- mc.click_menus_in_sequence(mc.e("remoteContentOptions"), [
- { id: "remoteContentOptionAllowForMsg" },
- ]);
- wait_for_notification_to_stop(mc, kBoxId, kNotificationValue);
-
- wait_for_message_display_completion(mc, true);
-
- if (
- !test.checkForAllowed(
- mc.window.content.document.getElementById("testelement")
- )
- ) {
- throw new Error(
- test.type + " has been unexpectedly blocked in message content"
- );
- }
-}
-
-function checkContentTab(test) {
- // To open a tab we're going to have to cheat and use tabmail so we can load
- // in the data of what we want.
- let preCount = mc.tabmail.tabContainer.allTabs.length;
-
- let newTab = open_content_tab_with_url(url + test.webPage);
-
- if (
- !test.checkForAllowed(
- mc.window.content.document.getElementById("testelement")
- )
- ) {
- throw new Error(
- test.type + " has been unexpectedly blocked in content tab"
- );
- }
-
- mc.tabmail.closeTab(newTab);
-
- if (mc.tabmail.tabContainer.allTabs.length != preCount) {
- throw new Error("The content tab didn't close");
- }
-}
-
-/**
- * Check remote content is not blocked in feed message (flagged with
- * nsMsgMessageFlags::FeedMsg)
- */
-function checkAllowFeedMsg(test) {
- let msgDbHdr = addToFolder(
- test.type + " test feed message " + gMsgNo,
- msgBodyStart + test.body + msgBodyEnd,
- folder
- );
- msgDbHdr.OrFlags(Ci.nsMsgMessageFlags.FeedMsg);
-
- // select the newly created message
- let msgHdr = select_click_row(gMsgNo);
-
- assert_equals(msgDbHdr, msgHdr);
- assert_selected_and_displayed(gMsgNo);
-
- // Now check that the content hasn't been blocked
- if (
- !test.checkForAllowed(
- mc.window.content.document.getElementById("testelement")
- )
- ) {
- throw new Error(
- test.type + " has been unexpectedly blocked in feed message content."
- );
- }
-
- ++gMsgNo;
-}
-
-/**
- * Check remote content is not blocked for a sender with permissions.
- */
-function checkAllowForSenderWithPerms(test) {
- let msgDbHdr = addToFolder(
- test.type + " priv sender test message " + gMsgNo,
- msgBodyStart + test.body + msgBodyEnd,
- folder
- );
-
- let addresses = MailServices.headerParser.parseEncodedHeader(msgDbHdr.author);
- let authorEmailAddress = addresses[0].email;
-
- let uri = Services.io.newURI(
- "chrome://messenger/content/email=" + authorEmailAddress
- );
- addPermission(uri, Services.perms.ALLOW_ACTION);
- assert_equals(checkPermission(uri), Services.perms.ALLOW_ACTION);
-
- // select the newly created message
- let msgHdr = select_click_row(gMsgNo);
-
- assert_equals(msgDbHdr, msgHdr);
- assert_selected_and_displayed(gMsgNo);
-
- // Now check that the content hasn't been blocked
- if (
- !test.checkForAllowed(
- mc.window.content.document.getElementById("testelement")
- )
- ) {
- throw new Error(
- `${
- test.type
- } has been unexpectedly blocked for sender=${authorEmailAddress}`
- );
- }
-
- // Clean up after ourselves, and make sure that worked as expected.
- removePermission(uri);
- assert_equals(checkPermission(uri), Services.perms.UNKNOWN_ACTION);
-
- ++gMsgNo;
-}
-
-/**
- * Check remote content is not blocked for a hosts with permissions.
- */
-function checkAllowForHostsWithPerms(test) {
- let msgDbHdr = addToFolder(
- test.type + " priv host test message " + gMsgNo,
- msgBodyStart + test.body + msgBodyEnd,
- folder
- );
-
- // Select the newly created message.
- let msgHdr = select_click_row(gMsgNo);
- assert_equals(msgDbHdr, msgHdr);
- assert_selected_and_displayed(gMsgNo);
-
- let src = mc.window.content.document.getElementById("testelement").src;
-
- if (!src.startsWith("http")) {
- // Just test http in this test.
- return;
- }
-
- let uri = Services.io.newURI(src);
- addPermission(uri, Services.perms.ALLOW_ACTION);
- assert_equals(checkPermission(uri), Services.perms.ALLOW_ACTION);
-
- // Click back one msg, then the original again, which should now allow loading.
- select_click_row(gMsgNo - 1);
- // Select the newly created message.
- msgHdr = select_click_row(gMsgNo);
- assert_equals(msgDbHdr, msgHdr);
- assert_selected_and_displayed(gMsgNo);
-
- // Now check that the content hasn't been blocked.
- if (
- !test.checkForAllowed(
- mozmill
- .getMail3PaneController()
- .window.content.document.getElementById("testelement")
- )
- ) {
- throw new Error(
- test.type + " has been unexpectedly blocked for url=" + uri.spec
- );
- }
-
- // Clean up after ourselves, and make sure that worked as expected.
- removePermission(uri);
- assert_equals(checkPermission(uri), Services.perms.UNKNOWN_ACTION);
-
- ++gMsgNo;
-}
-
-function test_generalContentPolicy() {
- be_in_folder(folder);
-
- assert_nothing_selected();
-
- for (let i = 0; i < TESTS.length; ++i) {
- // Check for denied in mail
- addMsgToFolderAndCheckContent(folder, TESTS[i]);
-
- if (TESTS[i].checkDenied) {
- // Check denied in reply window
- checkComposeWindow(TESTS[i], true, false);
-
- // Check denied in forward window
- checkComposeWindow(TESTS[i], false, false);
-
- if (i == 0) {
- // Now check that image is visible after site is whitelisted.
- // We do the first test which is the one with the image.
-
- // Add the site to the whitelist.
- let src = mc.window.content.document.getElementById("testelement").src;
-
- let uri = Services.io.newURI(src);
- addPermission(uri, Services.perms.ALLOW_ACTION);
- assert_equals(checkPermission(uri), Services.perms.ALLOW_ACTION);
-
- // Check allowed in reply window
- checkComposeWindow(TESTS[i], true, true);
-
- // Check allowed in forward window
- checkComposeWindow(TESTS[i], false, true);
-
- // Clean up after ourselves, and make sure that worked as expected.
- removePermission(uri);
- assert_equals(checkPermission(uri), Services.perms.UNKNOWN_ACTION);
- }
-
- // Check denied in standalone message window
- checkStandaloneMessageWindow(TESTS[i], false);
-
- // Now allow the remote content and check result
- allowRemoteContentAndCheck(TESTS[i]);
- }
-
- // Check allowed in reply window
- checkComposeWindow(TESTS[i], true, true);
-
- // Check allowed in forward window
- checkComposeWindow(TESTS[i], false, true);
-
- // Check allowed in standalone message window
- checkStandaloneMessageWindow(TESTS[i], true);
-
- // Check allowed in content tab
- checkContentTab(TESTS[i]);
-
- // Check allowed in a feed message
- checkAllowFeedMsg(TESTS[i]);
-
- // Check per sender privileges.
- checkAllowForSenderWithPerms(TESTS[i]);
-
- // Check per host privileges.
- checkAllowForHostsWithPerms(TESTS[i]);
-
- // Only want to do this for the first test case, which is a remote image.
- if (i == 0) {
- let emlFile = saveAsEMLFile(i);
- checkEMLMessageWindow(TESTS[i], emlFile);
- emlFile.remove(false);
- }
- }
-}
-
-// Copied from test-blocked-content.js.
-function putHTMLOnClipboard(html) {
- let trans = Cc["@mozilla.org/widget/transferable;1"].createInstance(
- Ci.nsITransferable
- );
-
- // Register supported data flavors
- trans.init(null);
- trans.addDataFlavor("text/html");
-
- let wapper = Cc["@mozilla.org/supports-string;1"].createInstance(
- Ci.nsISupportsString
- );
- wapper.data = html;
- trans.setTransferData("text/html", wapper);
-
- Services.clipboard.setData(trans, null, Ci.nsIClipboard.kGlobalClipboard);
-}
-
-function subtest_insertImageIntoReplyForward(aReplyType) {
- let msgDbHdr = addToFolder(
- "Test insert image into reply or forward",
- "Stand by for image insertion ;-)",
- folder
- );
- gMsgNo++;
-
- // Select the newly created message.
- be_in_folder(folder);
- let msgHdr = select_click_row(gMsgNo);
-
- if (msgDbHdr != msgHdr) {
- throw new Error(
- "Selected Message Header is not the same as generated header"
- );
- }
-
- assert_selected_and_displayed(gMsgNo);
-
- let replyWindow = aReplyType
- ? open_compose_with_reply()
- : open_compose_with_forward();
-
- // Now insert the image
- // (copied from test-compose-mailto.js:test_checkInsertImage()).
-
- // First focus on the editor element
- replyWindow.e("content-frame").focus();
-
- // Now open the image window
- plan_for_modal_dialog("Mail:image", function insert_image(mwc) {
- // Insert the url of the image.
- let srcloc = mwc.window.document.getElementById("srcInput");
- srcloc.focus();
-
- input_value(mwc, url + "pass.png");
- mwc.sleep(0);
-
- // Don't add alternate text
- mwc.click(mwc.eid("noAltTextRadio"));
-
- // Accept the dialog
- mwc.window.document.querySelector("dialog").acceptDialog();
- });
- replyWindow.click(replyWindow.eid("insertImage"));
-
- wait_for_modal_dialog();
- wait_for_window_close();
-
- // Paste an image.
- putHTMLOnClipboard("<img id='tmp-img' src='" + url + "pass.png' />");
-
- // Ctrl+V = Paste
- replyWindow.keypress(null, "v", { shiftKey: false, accelKey: true });
-
- // Now wait for the paste.
- replyWindow.waitFor(function() {
- let img = replyWindow
- .e("content-frame")
- .contentDocument.getElementById("tmp-img");
- return img != null;
- }, "Timeout waiting for pasted tmp image to be loaded ok");
-
- // Test that the image load has not been denied
- let childImages = replyWindow
- .e("content-frame")
- .contentDocument.getElementsByTagName("img");
-
- if (childImages.length != 2) {
- throw new Error(
- "Expecting one image in document, actually have " + childImages.length
- );
- }
-
- // Check both images.
- if (childImages[0].imageBlockingStatus != Ci.nsIContentPolicy.ACCEPT) {
- throw new Error("Loading of image has been unexpectedly blocked (1)");
- }
- if (childImages[1].imageBlockingStatus != Ci.nsIContentPolicy.ACCEPT) {
- throw new Error("Loading of image has been unexpectedly blocked (2)");
- }
-
- close_compose_window(replyWindow);
-}
-
-function test_insertImageIntoReply() {
- subtest_insertImageIntoReplyForward(true);
-}
-
-function test_insertImageIntoForward() {
- subtest_insertImageIntoReplyForward(false);
-}
deleted file mode 100644
--- a/mail/test/mozmill/content-policy/test-js-content-policy.js
+++ /dev/null
@@ -1,336 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests whether JavaScript in a local/remote message works.
- *
- * @note This assumes an existing local account, and will cause the Trash
- * folder of that account to be emptied multiple times.
- */
-
-"use strict";
-
-var {
- assert_equals,
- assert_nothing_selected,
- assert_selected_and_displayed,
- be_in_folder,
- close_tab,
- create_folder,
- mc,
- open_selected_message_in_new_tab,
- select_click_row,
- select_none,
- wait_for_message_display_completion,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var folder = null;
-
-// RELATIVE_ROOT messes with the collector, so we have to bring the path back
-// so we get the right path for the resources.
-var url = collector.addHttpResource("../content-policy/html", "content");
-
-function setupModule(module) {
- folder = create_folder("jsContentPolicy");
- Services.prefs.setBoolPref("javascript.enabled", true);
-}
-
-function teardownModule(module) {
- Services.prefs.clearUserPref("javascript.enabled");
-}
-
-function addToFolder(aSubject, aBody, aFolder) {
- let msgId =
- Cc["@mozilla.org/uuid-generator;1"]
- .getService(Ci.nsIUUIDGenerator)
- .generateUUID() + "@mozillamessaging.invalid";
-
- let source =
- "From - Sat Nov 1 12:39:54 2008\n" +
- "X-Mozilla-Status: 0001\n" +
- "X-Mozilla-Status2: 00000000\n" +
- "Message-ID: <" +
- msgId +
- ">\n" +
- "Date: Wed, 11 Jun 2008 20:32:02 -0400\n" +
- "From: Tester <tests@mozillamessaging.invalid>\n" +
- "User-Agent: Thunderbird 3.0a2pre (Macintosh/2008052122)\n" +
- "MIME-Version: 1.0\n" +
- "To: recipient@mozillamessaging.invalid\n" +
- "Subject: " +
- aSubject +
- "\n" +
- "Content-Type: text/html; charset=ISO-8859-1\n" +
- "Content-Transfer-Encoding: 7bit\n" +
- "Content-Base: " +
- url +
- "remote-noscript.html\n" +
- "\n" +
- aBody +
- "\n";
-
- aFolder.QueryInterface(Ci.nsIMsgLocalMailFolder);
- aFolder.gettingNewMessages = true;
-
- aFolder.addMessage(source);
- aFolder.gettingNewMessages = false;
-
- return aFolder.msgDatabase.getMsgHdrForMessageID(msgId);
-}
-
-var jsMsgBody =
- '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\n' +
- "<html>\n" +
- "<head>\n" +
- "\n" +
- '<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">\n' +
- "</head>\n" +
- '<body bgcolor="#ffffff" text="#000000">\n' +
- "this is a test<big><big><big> stuff\n" +
- "<br><br>\n" +
- "</big></big></big>\n" +
- "<noscript>\n" +
- "hello, this content is noscript!\n" +
- "</noscript>\n" +
- "<script>\n" +
- "var jsIsTurnedOn = true;\n" +
- "</script>\n" +
- "\n" +
- "</body>\n" +
- "</html>\n";
-
-var gMsgNo = 0;
-
-function checkJsInMail() {
- let msgDbHdr = addToFolder("JS test message " + gMsgNo, jsMsgBody, folder);
-
- // select the newly created message
- let msgHdr = select_click_row(gMsgNo);
-
- if (msgDbHdr != msgHdr) {
- throw new Error(
- "Selected Message Header is not the same as generated header"
- );
- }
-
- assert_selected_and_displayed(gMsgNo);
-
- let mc = mozmill.getMail3PaneController();
- // This works because messagepane is type=content-primary in these tests.
- if (typeof mc.window.content.wrappedJSObject.jsIsTurnedOn != "undefined") {
- throw new Error("JS is turned on in mail - it shouldn't be.");
- }
-
- let noscript = mc.window.content.wrappedJSObject.document.getElementsByTagName(
- "noscript"
- )[0];
- let display = mc.window
- .getComputedStyle(noscript)
- .getPropertyValue("display");
- if (display != "inline") {
- throw new Error("noscript display should be 'inline'; display=" + display);
- }
-
- ++gMsgNo;
-}
-
-function checkJsInNonMessageContent() {
- // Deselect everything so we can load our content
- select_none();
-
- let mc = mozmill.getMail3PaneController();
-
- // load something non-message-like in the message pane
- mc.window.GetMessagePaneFrame().location.href =
- "data:text/html;charset=utf-8,<script>var jsIsTurnedOn%3Dtrue%3B<%2Fscript>bar" +
- "<noscript><p id='noscript-p'>hey this is noscript</p>";
-
- wait_for_message_display_completion();
-
- if (!mc.window.content.wrappedJSObject.jsIsTurnedOn) {
- throw new Error("JS is not turned on in content - it should be.");
- }
-
- let noscript = mc.window.content.wrappedJSObject.document.getElementsByTagName(
- "noscript"
- )[0];
- let display = mc.window
- .getComputedStyle(noscript)
- .getPropertyValue("display");
- if (display != "none") {
- throw new Error("noscript display should be 'none'; display=" + display);
- }
-}
-
-/**
- * Check JavaScript for a feed message, when the "View as Web Page" pref is set.
- */
-function checkJsInFeedContent() {
- let msgDbHdr = addToFolder(
- "JS test message " + gMsgNo + " (feed!)",
- jsMsgBody,
- folder
- );
- msgDbHdr.OrFlags(Ci.nsMsgMessageFlags.FeedMsg);
-
- // Set to "View as Web Page" so we get the Content-Base page shown.
- Services.prefs.setIntPref("rss.show.summary", 0);
-
- // select the newly created message
- let msgHdr = select_click_row(gMsgNo);
- assert_equals(
- msgDbHdr,
- msgHdr,
- "Selected Message Header is not the same as generated header"
- );
-
- wait_for_message_display_completion();
-
- // The above just ensures local "inline" content have loaded. We need to wait
- // for the remote content to load too before we check anything.
- let mc = mozmill.getMail3PaneController();
- let feedUrl = url + "remote-noscript.html";
- mc.waitFor(
- () =>
- mc.window.content.wrappedJSObject.location.href == feedUrl &&
- mc.window.content.wrappedJSObject.document &&
- mc.window.content.wrappedJSObject.document.querySelector("body") != null,
- () =>
- "Timeout waiting for remote feed doc to load; url=" +
- mc.window.content.wrappedJSObject.location
- );
-
- if (!mc.window.content.wrappedJSObject.jsIsTurnedOn) {
- throw new Error(
- "JS is turned off for remote feed content - it should be on."
- );
- }
-
- let noscript = mc.window.content.wrappedJSObject.document.getElementsByTagName(
- "noscript"
- )[0];
- let display = mc.window
- .getComputedStyle(noscript)
- .getPropertyValue("display");
- if (display != "none") {
- throw new Error("noscript display should be 'none'; display=" + display);
- }
-
- ++gMsgNo;
-
- Services.prefs.clearUserPref("rss.show.summary");
-}
-
-/**
- * Check JavaScript for a feed message viewed in a tab, when the
- * "View as Web Page" pref is set.
- */
-function checkJsInFeedTab() {
- let msgDbHdr = addToFolder(
- "JS test message " + gMsgNo + " (feed!)",
- jsMsgBody,
- folder
- );
- msgDbHdr.OrFlags(Ci.nsMsgMessageFlags.FeedMsg);
-
- // Set to "View as Web Page" so we get the Content-Base page shown.
- Services.prefs.setIntPref("rss.show.summary", 0);
-
- // Select the newly created message.
- let msgHdr = select_click_row(gMsgNo);
- assert_equals(
- msgDbHdr,
- msgHdr,
- "Selected Message Header is not the same as generated header"
- );
-
- wait_for_message_display_completion();
-
- let feedUrl = url + "remote-noscript.html";
-
- open_selected_message_in_new_tab();
-
- // The above just ensures local "inline" content have loaded. We need to wait
- // for the remote content to load too before we check anything.
- mc.waitFor(
- () =>
- mc.window.content.wrappedJSObject.location.href == feedUrl &&
- mc.window.content.wrappedJSObject.document &&
- mc.window.content.wrappedJSObject.document.querySelector("body") != null,
- () =>
- "Timeout waiting for remote feed doc to load; url=" +
- mc.window.content.wrappedJSObject.location
- );
-
- if (!mc.window.content.wrappedJSObject.jsIsTurnedOn) {
- throw new Error(
- "JS is turned off for remote feed content - it should be on."
- );
- }
-
- let noscript = mc.window.content.wrappedJSObject.document.getElementsByTagName(
- "noscript"
- )[0];
- let display = mc.window
- .getComputedStyle(noscript)
- .getPropertyValue("display");
- if (display != "none") {
- throw new Error("noscript display should be 'none'; display=" + display);
- }
-
- ++gMsgNo;
-
- Services.prefs.clearUserPref("rss.show.summary");
- close_tab();
-}
-
-/**
- * Check JavaScript when loading remote content in the message pane.
- */
-function checkJsInRemoteContent() {
- // Deselect everything so we can load our content
- select_none();
-
- let mc = mozmill.getMail3PaneController();
- // load something non-message-like in the message pane
- mc.window.GetMessagePaneFrame().location.href = url + "remote-noscript.html";
- wait_for_message_display_completion();
-
- if (!mc.window.content.wrappedJSObject.jsIsTurnedOn) {
- throw new Error("JS is not turned on in content - it should be.");
- }
-
- let noscript = mc.window.content.wrappedJSObject.document.getElementsByTagName(
- "noscript"
- )[0];
- let display = mc.window
- .getComputedStyle(noscript)
- .getPropertyValue("display");
- if (display != "none") {
- throw new Error("noscript display should be 'none'; display=" + display);
- }
-}
-
-function test_jsContentPolicy() {
- be_in_folder(folder);
-
- assert_nothing_selected();
-
- // run each test twice to ensure that there aren't any weird side effects,
- // given that these loads all happen in the same docshell
-
- checkJsInMail();
- checkJsInNonMessageContent();
-
- checkJsInMail();
- checkJsInNonMessageContent();
-
- checkJsInFeedContent();
- checkJsInRemoteContent();
- checkJsInFeedTab();
-}
deleted file mode 100644
--- a/mail/test/mozmill/content-policy/test-plugins-policy.js
+++ /dev/null
@@ -1,232 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Checks if plugins are enabled in messages correctly or not.
- * As of bug 1508942, plugins are no longer enabled in any context.
- */
-
-"use strict";
-
-var composeHelper = ChromeUtils.import(
- "resource://testing-common/mozmill/ComposeHelpers.jsm"
-);
-var { open_content_tab_with_url } = ChromeUtils.import(
- "resource://testing-common/mozmill/ContentTabHelpers.jsm"
-);
-
-var {
- assert_nothing_selected,
- assert_selected_and_displayed,
- be_in_folder,
- close_message_window,
- create_folder,
- mc,
- open_selected_message,
- select_click_row,
- select_none,
- set_open_message_behavior,
- wait_for_message_display_completion,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { plan_for_new_window, wait_for_new_window } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var folder = null;
-var gMsgNo = 0;
-
-// RELATIVE_ROOT messes with the collector, so we have to bring the path back
-// so we get the right path for the resources.
-var url = collector.addHttpResource("../content-policy/html", "content");
-
-// These two constants are used to build the message body.
-var msgBody =
- '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\n' +
- "<html>\n" +
- "<head>\n" +
- "\n" +
- '<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">\n' +
- "</head>\n" +
- '<body bgcolor="#ffffff" text="#000000">\n' +
- '<embed id="testelement" type="application/x-test" width="400" height="400" border="1"></embed>\n' +
- "</body>\n</html>\n";
-
-function setupModule(module) {
- folder = create_folder("pluginPolicy");
-}
-
-function addToFolder(aSubject, aBody, aFolder) {
- let msgId =
- Cc["@mozilla.org/uuid-generator;1"]
- .getService(Ci.nsIUUIDGenerator)
- .generateUUID() + "@mozillamessaging.invalid";
-
- let source =
- "From - Sat Nov 1 12:39:54 2008\n" +
- "X-Mozilla-Status: 0001\n" +
- "X-Mozilla-Status2: 00000000\n" +
- "Message-ID: <" +
- msgId +
- ">\n" +
- "Date: Wed, 11 Jun 2008 20:32:02 -0400\n" +
- "From: Tester <tests@mozillamessaging.invalid>\n" +
- "User-Agent: Thunderbird 3.0a2pre (Macintosh/2008052122)\n" +
- "MIME-Version: 1.0\n" +
- "To: recipient@mozillamessaging.invalid\n" +
- "Subject: " +
- aSubject +
- "\n" +
- "Content-Type: text/html; charset=ISO-8859-1\n" +
- "Content-Transfer-Encoding: 7bit\n" +
- "\n" +
- aBody +
- "\n";
-
- aFolder.QueryInterface(Ci.nsIMsgLocalMailFolder);
- aFolder.gettingNewMessages = true;
-
- aFolder.addMessage(source);
- aFolder.gettingNewMessages = false;
-
- return aFolder.msgDatabase.getMsgHdrForMessageID(msgId);
-}
-
-function isPluginLoaded(contentDocument) {
- let element = contentDocument.getElementById("testelement").wrappedJSObject;
-
- try {
- // if setColor throws, then the plugin isn't running
- element.setColor("FFFF0000");
- return true;
- } catch (ex) {
- // Any errors and we'll just return false below - they may be expected.
- }
- return false;
-}
-
-function addMsgToFolderAndCheckContent(loadAllowed) {
- let msgDbHdr = addToFolder("Plugin test message " + gMsgNo, msgBody, folder);
-
- // select the newly created message
- let msgHdr = select_click_row(gMsgNo);
-
- if (msgDbHdr != msgHdr) {
- throw new Error(
- "Selected Message Header is not the same as generated header"
- );
- }
-
- assert_selected_and_displayed(gMsgNo);
-
- ++gMsgNo;
-
- // XXX It appears the assert_selected_and_displayed doesn't actually wait
- // long enough for plugin load. However, I also can't find a way to wait for
- // long enough in all situations, so this will have to do for now.
- mc.sleep(1000);
-
- // Now check that the content hasn't been loaded
- if (
- isPluginLoaded(mozmill.getMail3PaneController().window.content.document) !=
- loadAllowed
- ) {
- throw new Error(
- loadAllowed
- ? "Plugin has been unexpectedly blocked in message content"
- : "Plugin has not been blocked in message as expected"
- );
- }
-}
-
-function checkStandaloneMessageWindow(loadAllowed) {
- plan_for_new_window("mail:messageWindow");
- // Open it
- set_open_message_behavior("NEW_WINDOW");
-
- open_selected_message();
- let msgc = wait_for_new_window("mail:messageWindow");
- wait_for_message_display_completion(msgc, true);
-
- // XXX It appears the wait_for_message_display_completion doesn't actually
- // wait long enough for plugin load. However, I also can't find a way to wait
- // for long enough in all situations, so this will have to do for now.
- mc.sleep(1000);
-
- if (isPluginLoaded(msgc.window.content.document) != loadAllowed) {
- throw new Error(
- loadAllowed
- ? "Plugin has been unexpectedly blocked in standalone window"
- : "Plugin has not been blocked in standalone window as expected"
- );
- }
-
- // Clean up, close the window
- close_message_window(msgc);
-}
-
-function test_3paneWindowDenied() {
- be_in_folder(folder);
-
- assert_nothing_selected();
-
- addMsgToFolderAndCheckContent(false);
-}
-
-function test_checkPluginsInNonMessageContent() {
- // Deselect everything so we can load our content
- select_none();
-
- // load something non-message-like in the message pane
- mozmill.getMail3PaneController().window.GetMessagePaneFrame().location.href =
- url + "plugin.html";
-
- wait_for_message_display_completion();
-
- if (
- isPluginLoaded(mozmill.getMail3PaneController().window.content.document)
- ) {
- throw new Error(
- "Plugin is turned on in content in message pane - it should not be."
- );
- }
-}
-
-function test_3paneWindowDeniedAgain() {
- select_click_row(0);
-
- assert_selected_and_displayed(0);
-
- // Now check that the content hasn't been loaded
- if (
- isPluginLoaded(mozmill.getMail3PaneController().window.content.document)
- ) {
- throw new Error("Plugin has not been blocked in message as expected");
- }
-}
-
-function test_checkStandaloneMessageWindowDenied() {
- checkStandaloneMessageWindow(false);
-}
-
-function test_checkContentTab() {
- // To open a tab we're going to have to cheat and use tabmail so we can load
- // in the data of what we want.
- let preCount = mc.tabmail.tabContainer.allTabs.length;
-
- let newTab = open_content_tab_with_url(url + "plugin.html");
-
- if (isPluginLoaded(mc.tabmail.getBrowserForSelectedTab().contentDocument)) {
- throw new Error("Plugin has been unexpectedly not blocked in content tab");
- }
-
- mc.tabmail.closeTab(newTab);
-
- if (mc.tabmail.tabContainer.allTabs.length != preCount) {
- throw new Error("The content tab didn't close");
- }
-}
deleted file mode 100644
--- a/mail/test/mozmill/content-policy/test-view-source.js
+++ /dev/null
@@ -1,138 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Test that view-source content can be reloaded to change encoding.
- */
-
-"use strict";
-
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-
-var {
- assert_true,
- be_in_folder,
- create_folder,
- mc,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var {
- close_window,
- plan_for_new_window,
- wait_for_new_window,
-} = ChromeUtils.import("resource://testing-common/mozmill/WindowHelpers.jsm");
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var folder = null;
-
-function setupModule(module) {
- folder = create_folder("viewsource");
-}
-
-function addToFolder(aSubject, aBody, aFolder) {
- let msgId =
- Cc["@mozilla.org/uuid-generator;1"]
- .getService(Ci.nsIUUIDGenerator)
- .generateUUID() + "@invalid";
-
- let source =
- "From - Sat Nov 1 12:39:54 2008\n" +
- "X-Mozilla-Status: 0001\n" +
- "X-Mozilla-Status2: 00000000\n" +
- "Message-ID: <" +
- msgId +
- ">\n" +
- "Date: Wed, 11 Jun 2008 20:32:02 -0400\n" +
- "From: Tester <tests@mozillamessaging.invalid>\n" +
- "MIME-Version: 1.0\n" +
- "To: anna@example.com\n" +
- "Subject: " +
- aSubject +
- "\n" +
- "Content-Type: text/plain; charset=ISO-8859-1\n" +
- "Content-Transfer-Encoding: 7bit\n" +
- "\n" +
- aBody +
- "\n";
-
- aFolder.QueryInterface(Ci.nsIMsgLocalMailFolder);
- aFolder.addMessage(source);
-
- return aFolder.msgDatabase.getMsgHdrForMessageID(msgId);
-}
-
-/**
- * Test that the view source character encoding can be changed,
- * which requires content policy is correct for view-source:.
- */
-function test_view_source_reload() {
- be_in_folder(folder);
-
- let contentLatin1 = "Testar, ett två tre.";
- let contentUTF8 = "Testar, ett tv� tre";
- let msg = addToFolder("view-source reload test123?", contentLatin1, folder);
-
- let selMsg = select_click_row(0);
- assert_true(
- msg == selMsg,
- "Selected msg isn't the same as the generated one."
- );
-
- plan_for_new_window("navigator:view-source");
- mc.keypress(null, "U", { shiftKey: false, accelKey: true });
- let vsc = wait_for_new_window("navigator:view-source");
-
- vsc.waitFor(
- () => vsc.e("content").contentDocument.querySelector("pre") != null,
- "Timeout waiting for the latin1 view-source document to load."
- );
-
- let source = vsc.e("content").contentDocument.querySelector("pre")
- .textContent;
- if (!source.includes(contentLatin1)) {
- throw new Error(
- "View source didn't contain the latin1 text;\n" +
- contentLatin1 +
- "\n" +
- source
- );
- }
-
- let doc = vsc.e("content").contentDocument; // keep a ref to the latin1 doc
-
- // Click the new window to make it receive further events properly.
- vsc.click(vsc.eid("content"));
-
- vsc.click(vsc.eid("menu_view"));
- vsc.click_menus_in_sequence(vsc.e("viewmenu-popup"), [
- { id: "charsetMenu" },
- { label: "Unicode" },
- ]);
-
- vsc.waitFor(
- () =>
- vsc.e("content").contentDocument != doc &&
- vsc.e("content").contentDocument.querySelector("pre") != null,
- "Timeout waiting utf-8 encoded view-source document to load."
- );
-
- source = vsc.e("content").contentDocument.querySelector("pre").textContent;
- if (!source.includes(contentUTF8)) {
- throw new Error(
- "View source didn't contain the utf-8 text;\n" +
- contentUTF8 +
- "\n" +
- source
- );
- }
-
- close_window(vsc);
-}
-// Skip on Mac, as we can't click the (native) menus to make it work.
-test_view_source_reload.EXCLUDED_PLATFORMS = ["darwin"];
deleted file mode 100644
--- a/mail/test/mozmill/content-tabs/html/blocklist.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist">
- <pluginItems>
- <pluginItem>
- <match name="name" exp="Test Plug-in"/>
- <versionRange severity="0"/>
- </pluginItem>
- </pluginItems>
-</blocklist>
deleted file mode 100644
--- a/mail/test/mozmill/content-tabs/html/blocklistHard.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist">
- <pluginItems>
- <pluginItem blockID="p9999">
- <match name="name" exp="Test Plug-in"/>
- <versionRange severity="2"/>
- </pluginItem>
- </pluginItems>
-</blocklist>
deleted file mode 100644
--- a/mail/test/mozmill/content-tabs/html/blocklist_details.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<html>
- <head>
- <title>Plugin Blocklist Details</title>
- </head>
- <body bgcolor="#FFFFFF">
- <h1>Plugin Blocklist Details Page</h1>
- </body>
-</html>
deleted file mode 100644
index 0d9fb59d08f93cb304b11451cf4cb6846532aa83..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
--- a/mail/test/mozmill/content-tabs/html/dummy.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist">
-</blocklist>
deleted file mode 100644
index 0815759685e0cd54b363626b34ff8ff08403cd10..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
--- a/mail/test/mozmill/content-tabs/html/installxpi.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<html>
- <head>
- <title>Test xpi installation</title>
- </head>
- <body bgcolor="#FFFFFF">
- <h1>Test xpi installation</h1>
-
- <a id="corruptlink" href="corrupt.xpi">Install this corrupt xpi</a>
- <a id="installlink" href="installxpi.xpi">Install this xpi</a>
- <a id="installwebextlink" href="webextension.xpi">Install this webextension xpi</a>
-
- </body>
-</html>
deleted file mode 100644
index 854e1bafdf2e2b09e4116c8fd5773d95b57efca6..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
--- a/mail/test/mozmill/content-tabs/html/plugin.html
+++ /dev/null
@@ -1,9 +0,0 @@
-<html>
- <head>
- <title>Plugin Test</title>
- </head>
- <body bgcolor="#FFFFFF">
- <h1>Plugin Test</h1>
- <embed id="test-plugin" type="application/x-test" width="500" height="500"></embed>
- </body>
-</html>
deleted file mode 100644
--- a/mail/test/mozmill/content-tabs/html/plugin_crashed_help.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<html>
- <head>
- <title>Plugin Crashed Help</title>
- </head>
- <body bgcolor="#FFFFFF">
- <h1>Plugin Crashed Help</h1>
- </body>
-</html>
deleted file mode 100644
--- a/mail/test/mozmill/content-tabs/html/plugin_update.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<html>
- <head>
- <title>Plugin Update Page</title>
- </head>
- <body bgcolor="#FFFFFF">
- <h1>Plugin Update Page</h1>
- </body>
-</html>
deleted file mode 100644
--- a/mail/test/mozmill/content-tabs/html/test-lwthemes.html
+++ /dev/null
@@ -1,44 +0,0 @@
-<html><head>
-<title>test lightweight themes</title>
-</head><body>
-<script>
-var themes = [
- {
- id: "test-01",
- name: "Test 01",
- headerURL: "test.png",
- footerURL: "test.png",
- textcolor: "#fff",
- accentcolor: "#6b6b6b",
- },
- {
- id: "test-02",
- name: "Test 02",
- headerURL: "test.png",
- footerURL: "test.png",
- textcolor: "#bcf",
- accentcolor: "#8888FF",
- },
-];
-
-const INSTALL = "InstallBrowserTheme";
-const PREVIEW = "PreviewBrowserTheme";
-const RESET_PREVIEW = "ResetBrowserThemePreview";
-
-function setTheme(node, theme, action) {
- node.setAttribute("data-browsertheme", JSON.stringify(themes[theme]));
- dump("dispatching " + action + "\n");
- node.dispatchEvent(new Event(action, { bubbles: true, cancelable: false }));
-}
-</script>
-
-<button id="install1"
- onclick="setTheme(this, 0, INSTALL);"
- onmouseover="setTheme(this, 0, PREVIEW);"
- onmouseout="setTheme(this, 0, RESET_PREVIEW);">Test 01</button>
-<button id="install2"
- onclick="setTheme(this, 1, INSTALL);"
- onmouseover="setTheme(this, 1, PREVIEW);"
- onmouseout="setTheme(this, 1, RESET_PREVIEW);">Test 02</button>
-</body>
-</html>
deleted file mode 100644
index e3988bfc76f7c272f2bc853ac27b17e9980d08cd..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index d4e4f2750704b23af2218b9a8e10c32b370674bc..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
--- a/mail/test/mozmill/content-tabs/html/whatsnew.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<html>
- <head>
- <title>What's New Content Test</title>
- <link rel="icon shortcut" href="whatsnew.png"/>
- </head>
- <body bgcolor="#FFFFFF">
- <menu type="context" id="pageContextMenu">
- <menuitem label="Click me!" id="pageMenuItem"/>
- </menu>
- <h1 contextmenu="pageContextMenu">What's New Content Test</h1>
- <textarea>Zombocom</textarea>
- </body>
-</html>
deleted file mode 100644
index bb3ff3b0699162df43035f0c30403005f713d219..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
--- a/mail/test/mozmill/content-tabs/html/whatsnew1.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<html>
- <head>
- <title>What's New Content Test 1</title>
- </head>
- <body bgcolor="#FFFFFF">
- <h1>What's New Content Test 1</h1>
- </body>
-</html>
deleted file mode 100644
--- a/mail/test/mozmill/content-tabs/test-about-support.js
+++ /dev/null
@@ -1,497 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-var { close_compose_window, wait_for_compose_window } = ChromeUtils.import(
- "resource://testing-common/mozmill/ComposeHelpers.jsm"
-);
-var {
- assert_content_tab_element_hidden,
- assert_content_tab_element_visible,
- assert_content_tab_text_absent,
- assert_content_tab_text_present,
- content_tab_e,
- content_tab_eid,
- get_content_tab_element_display,
- get_element_by_text,
- open_content_tab_with_click,
- wait_for_content_tab_element_display,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/ContentTabHelpers.jsm"
-);
-
-var {
- assert_equals,
- assert_true,
- close_tab,
- mark_failure,
- mc,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { plan_for_new_window } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-// eslint-disable-next-line mozilla/reject-importGlobalProperties
-Cu.importGlobalProperties(["DOMParser"]);
-
-var warningText = new Map();
-
-function setupModule(module) {
- // The wording of the warning message when private data is being exported
- // from the about:support page.
- let bundle = Services.strings.createBundle(
- "chrome://messenger/locale/aboutSupportMail.properties"
- );
- // In HTML the warning label and text comprise the textContent of a single element.
- warningText.set(
- "text/html",
- bundle.GetStringFromName("warningLabel") +
- " " +
- bundle.GetStringFromName("warningText")
- );
- // In plain text the warning label may end up on a separate line so do not match it.
- warningText.set("text/unicode", bundle.GetStringFromName("warningText"));
-}
-
-// After every test we want to close the about:support tab so that failures
-// don't cascade.
-function teardownTest(module) {
- mc.tabmail.closeOtherTabs(mc.tabmail.tabInfo[0]);
-}
-
-/**
- * Strings found in the about:support HTML or text that should clearly mark the
- * data as being from about:support.
- */
-const ABOUT_SUPPORT_STRINGS = [
- "Application Basics",
- "Mail and News Accounts",
- "Extensions",
- "Important Modified Preferences",
- "Graphics",
- "JavaScript",
- "Accessibility",
- "Library Versions",
-];
-
-/**
- * Strings that if found in the about:support text or HTML usually indicate an
- * error.
- */
-const ABOUT_SUPPORT_ERROR_STRINGS = new Map([
- ["text/html", ["undefined", "null"]],
- ["text/unicode", ["undefined"]],
-]);
-
-/*
- * Helpers
- */
-
-/**
- * Opens about:support and waits for it to load.
- *
- * @returns the about:support tab.
- */
-function open_about_support() {
- let tab = open_content_tab_with_click(
- mc.menus.helpMenu.aboutsupport_open,
- "about:support"
- );
-
- // Make sure L10n is done.
- let l10nDone = false;
- tab.browser.contentDocument.l10n.ready.then(
- () => (l10nDone = true),
- Cu.reportError
- );
- mc.waitFor(() => l10nDone, "Timeout waiting for L10n to complete.");
-
- // We have one variable that's asynchronously populated -- wait for it to be
- // populated.
- mc.waitFor(
- () => tab.browser.contentWindow.gAccountDetails !== undefined,
- "Timeout waiting for about:support's gAccountDetails to populate."
- );
-
- mc.waitFor(
- () => content_tab_e(tab, "accounts-tbody").children.length > 1,
- "Accounts sections didn't load."
- );
- // The population of the info fields is async, so we must wait until
- // the last one is done.
- mc.waitFor(
- () =>
- content_tab_e(tab, "intl-osprefs-regionalprefs").textContent.trim() != "",
- "Regional prefs section didn't load."
- );
-
- return tab;
-}
-
-/**
- * Opens a compose window containing the troubleshooting information.
- *
- * @param aTab The about:support tab.
- */
-function open_send_via_email(aTab) {
- let button = content_tab_eid(aTab, "send-via-email");
- plan_for_new_window("msgcompose");
- mc.click(button);
- let cwc = wait_for_compose_window();
- return cwc;
-}
-
-/**
- * Find some element marked as private data.
- */
-function find_private_element(aTab) {
- // We use the identity name as an example of a private-only element.
- // It is currently the second td element with class="data-private" in the table.
- // The content string must be something unique that is not found anywhere else.
- let elem = aTab.browser.contentDocument.querySelector(
- "#accounts-table td.data-private~td.data-private"
- );
- assert_true(elem != null);
- assert_true(elem.textContent.length > 0);
- assert_equals(get_content_tab_element_display(aTab, elem), "none");
- return elem;
-}
-
-/*
- * Tests
- */
-
-/**
- * Test displaying the about:support page. Also perform a couple of basic tests
- * to check that no major errors have occurred. The basic tests are by no means
- * comprehensive.
- */
-function test_display_about_support() {
- let tab = open_about_support();
- // Check that the document has a few strings that indicate that we've loaded
- // the right page.
- for (let str of ABOUT_SUPPORT_STRINGS) {
- assert_content_tab_text_present(tab, str);
- }
-
- // Check that error strings aren't present anywhere
- for (let str of ABOUT_SUPPORT_ERROR_STRINGS.get("text/html")) {
- assert_content_tab_text_absent(tab, str);
- }
-
- // Bug 1339436
- // Test that the tables in the page are all populated with at least one row
- // in the tbody element.
- // An exception in the code could cause some to be empty.
- let tables = tab.browser.contentDocument.querySelectorAll("tbody");
- let emptyTables = [
- "graphics-failures-tbody",
- "graphics-tbody",
- "locked-prefs-tbody",
- "sandbox-syscalls-tbody",
- "crashes-tbody",
- "processes-tbody",
- ]; // some tables may be empty
- for (let table of tables) {
- if (!emptyTables.includes(table.id)) {
- assert_true(
- table.querySelectorAll("tr").length > 0,
- "Troubleshooting table '" + table.id + "' is empty!"
- );
- }
- }
-
- // Mozmill uses a user.js file in the profile, so the warning about the file
- // should be visible here.
- let userjsElem = tab.browser.contentDocument.getElementById(
- "prefs-user-js-section"
- );
- assert_true(userjsElem.hasChildNodes);
- assert_true(
- tab.browser.contentDocument.defaultView.getComputedStyle(userjsElem)
- .display == "block"
- );
- assert_true(
- tab.browser.contentDocument.defaultView.getComputedStyle(userjsElem)
- .visibility == "visible"
- );
-
- close_tab(tab);
-}
-
-/**
- * Test that our accounts are displayed in order.
- */
-function test_accounts_in_order() {
- let tab = open_about_support();
- // This is a really simple test and by no means comprehensive -- test that
- // "account1" appears before "account2" in the HTML content.
- assert_content_tab_text_present(tab, "account1");
- assert_content_tab_text_present(tab, "account2");
- let html = tab.browser.contentDocument.documentElement.innerHTML;
- if (html.indexOf("account1") > html.indexOf("account2")) {
- mark_failure(["account1 found after account2 in the HTML page"]);
- }
- close_tab(tab);
-}
-
-var UNIQUE_ID = "3a9e1694-7115-4237-8b1e-1cabe6e35073";
-
-/**
- * Test that a modified preference on the whitelist but not on the blacklist
- * shows up.
- */
-function test_modified_pref_on_whitelist() {
- const PREFIX = "accessibility.";
- let prefName = PREFIX + UNIQUE_ID;
- Services.prefs.setBoolPref(prefName, true);
- let tab = open_about_support();
-
- assert_content_tab_text_present(tab, prefName);
- close_tab(tab);
- Services.prefs.clearUserPref(prefName);
-}
-
-/**
- * Test that a modified preference not on the whitelist doesn't show up.
- */
-function test_modified_pref_not_on_whitelist() {
- Services.prefs.setBoolPref(UNIQUE_ID, true);
- let tab = open_about_support();
- assert_content_tab_text_absent(tab, UNIQUE_ID);
- close_tab(tab);
- Services.prefs.clearUserPref(UNIQUE_ID);
-}
-
-/**
- * Test that a modified preference on the blacklist doesn't show up.
- */
-function test_modified_pref_on_blacklist() {
- const PREFIX = "network.proxy.";
- let prefName = PREFIX + UNIQUE_ID;
- Services.prefs.setBoolPref(prefName, true);
- let tab = open_about_support();
-
- assert_content_tab_text_absent(tab, prefName);
- close_tab(tab);
- Services.prefs.clearUserPref(prefName);
-}
-
-/**
- * Test that private data isn't displayed by default, and that when it is
- * displayed, it actually shows up.
- */
-function test_private_data() {
- let tab = open_about_support();
- let checkbox = content_tab_eid(tab, "check-show-private-data");
-
- // We use the profile path and some other element as an example
- // of a private-only element.
- let privateElem1 = find_private_element(tab);
- let privateElem2 = content_tab_e(tab, "profile-dir-box");
- // We use the profile button as an example of a public element.
- let publicElem = content_tab_e(tab, "profile-dir-button");
-
- assert_true(
- !checkbox.checked,
- "Private data checkbox shouldn't be checked by default"
- );
- assert_content_tab_element_visible(tab, publicElem);
- assert_content_tab_element_hidden(tab, privateElem1);
- assert_content_tab_element_hidden(tab, privateElem2);
-
- // Now check the checkbox and see what happens.
- mc.click(checkbox);
- wait_for_content_tab_element_display(tab, privateElem1);
- wait_for_content_tab_element_display(tab, privateElem2);
- close_tab(tab);
-}
-
-/**
- * Checks if text fragment exists in the document.
- * If it is a node tree, find the element whole contents is the searched text.
- * If it is plain text string, just check in text is anywhere in it.
- *
- * @param aDocument A node tree or a string of plain text data.
- * @param aText The text to find in the document.
- */
-function check_text_in_body(aDocument, aText) {
- if (typeof aDocument == "object") {
- return get_element_by_text(aDocument, aText) != null;
- }
- return aDocument.includes(aText);
-}
-
-/**
- * Test (well, sort of) the copy to clipboard function with public data.
- */
-function test_copy_to_clipboard_public() {
- let tab = open_about_support();
- let privateElem = find_private_element(tab);
- // To avoid destroying the current contents of the clipboard, instead of
- // actually copying to it, we just retrieve what would have been copied to it
- let transferable = tab.browser.contentWindow.getClipboardTransferable();
- for (let flavor of ["text/html", "text/unicode"]) {
- let data = {};
- transferable.getTransferData(flavor, data);
- let text = data.value.QueryInterface(Ci.nsISupportsString).data;
- let contentBody;
- if (flavor == "text/html") {
- let parser = new DOMParser();
- contentBody = parser.parseFromString(text, "text/html").body;
- } else {
- contentBody = text;
- }
-
- for (let str of ABOUT_SUPPORT_STRINGS) {
- if (!check_text_in_body(contentBody, str)) {
- mark_failure([
- 'Unable to find "' + str + '" in flavor "' + flavor + '"',
- ]);
- }
- }
-
- for (let str of ABOUT_SUPPORT_ERROR_STRINGS.get(flavor)) {
- if (check_text_in_body(contentBody, str)) {
- mark_failure(['Found "' + str + '" in flavor "' + flavor + '"']);
- }
- }
-
- // Check that private data isn't in the output.
- if (check_text_in_body(contentBody, privateElem.textContent)) {
- mark_failure(['Found private data in flavor "' + flavor + '"']);
- }
- }
- close_tab(tab);
-}
-
-/**
- * Test (well, sort of) the copy to clipboard function with private data.
- */
-function test_copy_to_clipboard_private() {
- let tab = open_about_support();
-
- // Display private data.
- let privateElem = find_private_element(tab);
- mc.click(content_tab_eid(tab, "check-show-private-data"));
- wait_for_content_tab_element_display(tab, privateElem);
-
- // To avoid destroying the current contents of the clipboard, instead of
- // actually copying to it, we just retrieve what would have been copied to it
- let transferable = tab.browser.contentWindow.getClipboardTransferable();
- for (let flavor of ["text/html", "text/unicode"]) {
- let data = {};
- transferable.getTransferData(flavor, data);
- let text = data.value.QueryInterface(Ci.nsISupportsString).data;
- let contentBody;
- if (flavor == "text/html") {
- let parser = new DOMParser();
- contentBody = parser.parseFromString(text, "text/html").body;
- } else {
- contentBody = text;
- }
-
- for (let str of ABOUT_SUPPORT_STRINGS) {
- if (!check_text_in_body(contentBody, str)) {
- mark_failure([
- 'Unable to find "' + str + '" in flavor "' + flavor + '"',
- ]);
- }
- }
-
- for (let str of ABOUT_SUPPORT_ERROR_STRINGS.get(flavor)) {
- if (check_text_in_body(contentBody, str)) {
- mark_failure(['Found "' + str + '" in flavor "' + flavor + '"']);
- }
- }
-
- // Check that private data is in the output.
- if (!check_text_in_body(contentBody, privateElem.textContent)) {
- mark_failure(['Unable to find private data in flavor "' + flavor + '"']);
- }
-
- // Check that the warning text is in the output.
- if (!check_text_in_body(contentBody, warningText.get(flavor))) {
- mark_failure(['Unable to find warning text in flavor "' + flavor + '"']);
- }
- }
- close_tab(tab);
-}
-
-/**
- * Test opening the compose window with public data.
- */
-function test_send_via_email_public() {
- let tab = open_about_support();
- let privateElem = find_private_element(tab);
-
- let cwc = open_send_via_email(tab);
-
- let contentBody = cwc.e("content-frame").contentDocument.body;
-
- for (let str of ABOUT_SUPPORT_STRINGS) {
- if (!check_text_in_body(contentBody, str)) {
- mark_failure(['Unable to find "' + str + '" in compose window']);
- }
- }
-
- for (let str of ABOUT_SUPPORT_ERROR_STRINGS.get("text/html")) {
- if (check_text_in_body(contentBody, str)) {
- mark_failure(['Found "' + str + '" in compose window']);
- }
- }
-
- // Check that private data isn't in the output.
- if (check_text_in_body(contentBody, privateElem.textContent)) {
- mark_failure(["Found private data in compose window"]);
- }
-
- close_compose_window(cwc);
- close_tab(tab);
-}
-
-/**
- * Test opening the compose window with private data.
- */
-function test_send_via_email_private() {
- let tab = open_about_support();
-
- // Display private data.
- let privateElem = find_private_element(tab);
- mc.click(content_tab_eid(tab, "check-show-private-data"));
- wait_for_content_tab_element_display(tab, privateElem);
-
- let cwc = open_send_via_email(tab);
-
- let contentBody = cwc.e("content-frame").contentDocument.body;
-
- for (let str of ABOUT_SUPPORT_STRINGS) {
- if (!check_text_in_body(contentBody, str)) {
- mark_failure(['Unable to find "' + str + '" in compose window']);
- }
- }
-
- for (let str of ABOUT_SUPPORT_ERROR_STRINGS.get("text/html")) {
- if (check_text_in_body(contentBody, str)) {
- mark_failure(['Found "' + str + '" in compose window']);
- }
- }
-
- // Check that private data is in the output.
- if (!check_text_in_body(contentBody, privateElem.textContent)) {
- mark_failure(["Unable to find private data in compose window"]);
- }
-
- // Check that the warning text is in the output.
- if (!check_text_in_body(contentBody, warningText.get("text/html"))) {
- mark_failure(["Unable to find warning text in compose window"]);
- }
-
- close_compose_window(cwc);
- close_tab(tab);
-}
deleted file mode 100644
--- a/mail/test/mozmill/content-tabs/test-addons-mgr.js
+++ /dev/null
@@ -1,71 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-
-var { content_tab_e, wait_for_content_tab_load } = ChromeUtils.import(
- "resource://testing-common/mozmill/ContentTabHelpers.jsm"
-);
-var { assert_true, mc } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var {
- plan_for_modal_dialog,
- wait_for_modal_dialog,
- wait_for_window_close,
-} = ChromeUtils.import("resource://testing-common/mozmill/WindowHelpers.jsm");
-
-function test_open_addons_with_url() {
- mc.window.openAddonsMgr("addons://list/theme");
- mc.sleep(0);
-
- let tab = mc.tabmail.currentTabInfo;
- wait_for_content_tab_load(tab, "about:addons", 10000);
- assert_true(
- content_tab_e(tab, "category-theme").selected,
- "Themes category should be selected!"
- );
-
- mc.tabmail.switchToTab(0); // switch to 3pane
- mc.tabmail.closeTab(tab);
-}
-
-/**
- * Bug 1462923
- * Check if the "Tools->Add-on Options" menu item works and shows our add-on.
- * This relies on the MozMill extension having optionsURL defined in install.rdf,
- * however simplistic the preferences XUL document may be.
- */
-function test_addon_prefs() {
- // Open Add-on Options.
- const subview = mc.click_through_appmenu([{ id: "appmenu_addons" }]);
-
- plan_for_modal_dialog("mozmill-prefs", function(controller) {
- // Add |mc.sleep(1000);| here to see the popup dialog.
- controller.window.close();
- });
-
- // MozMill add-on should be somewhere in the list. When found, click it.
- let foundAddon = false;
- for (let item of subview.children) {
- if (
- item.tagName == "toolbarbutton" &&
- item.getAttribute("collapsed") != "true" &&
- item.label == "MozMill"
- ) {
- foundAddon = true;
- mc.click(new elib.Elem(item));
- break;
- }
- }
- assert_true(foundAddon);
-
- // Wait for the options dialog to open and close.
- wait_for_modal_dialog();
- wait_for_window_close();
-}
deleted file mode 100644
--- a/mail/test/mozmill/content-tabs/test-content-tab.js
+++ /dev/null
@@ -1,227 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-var controller = ChromeUtils.import(
- "chrome://mozmill/content/modules/controller.jsm"
-);
-var elementslib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-var EventUtils = ChromeUtils.import(
- "chrome://mozmill/content/stdlib/EventUtils.jsm"
-);
-var mozmill = ChromeUtils.import(
- "chrome://mozmill/content/modules/mozmill.jsm"
-);
-
-var {
- assert_content_tab_has_favicon,
- open_content_tab_with_url,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/ContentTabHelpers.jsm"
-);
-var { assert_element_visible, assert_element_not_visible } = ChromeUtils.import(
- "resource://testing-common/mozmill/DOMHelpers.jsm"
-);
-
-var {
- assert_equals,
- assert_not_equals,
- assert_tab_has_title,
- assert_true,
- close_popup,
- mc,
- wait_for_popup_to_open,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { plan_for_modal_dialog, wait_for_modal_dialog } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-// RELATIVE_ROOT messes with the collector, so we have to bring the path back
-// so we get the right path for the resources.
-// Note: this one adds to '' as we need to make sure that favicon.ico is in the
-// root directory.
-var url = collector.addHttpResource("../content-tabs/html", "");
-var whatsUrl = url + "whatsnew.html";
-
-function test_content_tab_open() {
- let tab = open_content_tab_with_url(whatsUrl);
-
- assert_tab_has_title(tab, "What's New Content Test");
- // Check the location of the what's new image, this is via the link element
- // and therefore should be set and not favicon.png.
- assert_content_tab_has_favicon(tab, url + "whatsnew.png");
-
- // Check that window.content is set up correctly wrt content-primary and
- // content-targetable.
- if (mc.window.content.location != whatsUrl) {
- throw new Error(
- 'window.content is not set to the url loaded, incorrect type="..."?'
- );
- }
-}
-
-/**
- * Just make sure that the context menu does what we expect in content tabs wrt.
- * spell checking options.
- */
-function test_spellcheck_in_content_tabs() {
- let tabmail = mc.tabmail;
- let w = tabmail.selectedTab.browser.contentWindow;
- let textarea = w.document.querySelector("textarea");
- let eidMailContext = mc.eid("mailContext");
-
- // Test a few random items
- mc.click(new elementslib.Elem(textarea));
- // Bug 364914 causes textareas to not be spell checked until they have been
- // focused at last once, so give the event loop a chance to spin.
- // Since bug 1370754 the inline spell checker waits 1 second, so let's
- // wait 2 seconds to be on the safe side.
- mc.sleep(2000);
- mc.rightClick(new elementslib.Elem(textarea));
- wait_for_popup_to_open(eidMailContext.getNode());
- assert_element_visible("mailContext-spell-dictionaries");
- assert_element_visible("mailContext-spell-check-enabled");
- assert_element_not_visible("mailContext-replySender"); // we're in a content tab!
- close_popup(mc, eidMailContext);
-
- // Different test
- mc.rightClick(new elementslib.Elem(w.document.body.firstElementChild));
- wait_for_popup_to_open(eidMailContext.getNode());
- assert_element_not_visible("mailContext-spell-dictionaries");
- assert_element_not_visible("mailContext-spell-check-enabled");
- close_popup(mc, eidMailContext);
-
- // Right-click on "zombocom" and add to dictionary
- EventUtils.synthesizeMouse(
- textarea,
- 5,
- 5,
- { type: "contextmenu", button: 2 },
- w
- );
- wait_for_popup_to_open(eidMailContext.getNode());
- let suggestions = mc.window.document.getElementsByClassName(
- "spell-suggestion"
- );
- assert_true(
- suggestions.length > 0,
- "What, is zombocom a registered word now?"
- );
- mc.click(mc.eid("mailContext-spell-add-to-dictionary"));
- close_popup(mc, eidMailContext);
-
- // Now check we don't have any suggestionss
- EventUtils.synthesizeMouse(
- textarea,
- 5,
- 5,
- { type: "contextmenu", button: 2 },
- w
- );
- wait_for_popup_to_open(eidMailContext.getNode());
- suggestions = mc.window.document.getElementsByClassName("spell-suggestion");
- assert_true(suggestions.length == 0, "But I just taught you this word!");
- close_popup(mc, eidMailContext);
-}
-
-function test_content_tab_context_menu() {
- let tabmail = mc.tabmail;
- let w = tabmail.selectedTab.browser.contentWindow;
- let heading = w.document.querySelector("h1");
- let mailContext = mc.e("mailContext");
-
- // Make sure the page's menu items are added on right-click.
- EventUtils.synthesizeMouse(
- heading,
- 5,
- 5,
- { type: "contextmenu", button: 2 },
- w
- );
- wait_for_popup_to_open(mailContext);
- assert_equals(mailContext.firstElementChild.label, "Click me!");
- assert_element_visible("page-menu-separator");
- close_popup(mc, new elementslib.Elem(mailContext));
-
- // Make sure the page's menu items are *not* added on shift-right-click.
- EventUtils.synthesizeMouse(
- heading,
- 5,
- 5,
- { type: "contextmenu", button: 2, shiftKey: true },
- w
- );
- wait_for_popup_to_open(mailContext);
- assert_not_equals(mailContext.firstElementChild.label, "Click me!");
- assert_element_not_visible("page-menu-separator");
- close_popup(mc, new elementslib.Elem(mailContext));
-}
-
-/*
- // We don't have an UI to test opening content tabs twice anymore.
-function test_content_tab_open_same() {
- let preCount = mc.tabmail.tabContainer.allTabs.length;
-
- mc.click(new elementslib.Elem(mc.menus.helpMenu.whatsNew));
-
- controller.sleep(0);
-
- if (mc.tabmail.tabContainer.allTabs.length != preCount)
- throw new Error("A new content tab was opened when it shouldn't have been");
-
- // Double-check browser is still the same.
- if (mc.window.content.location != whatsUrl)
- throw new Error("window.content is not set to the url loaded, incorrect type=\"...\"?");
-}
-*/
-
-function test_content_tab_default_favicon() {
- const whatsUrl2 = url + "whatsnew1.html";
- let tab = open_content_tab_with_url(whatsUrl2);
-
- assert_tab_has_title(tab, "What's New Content Test 1");
- // Check the location of the favicon, this should be the site favicon in this
- // test.
- assert_content_tab_has_favicon(tab, url + "favicon.ico");
-}
-
-function test_content_tab_onbeforeunload() {
- let count = mc.tabmail.tabContainer.allTabs.length;
- let tab = mc.tabmail.tabInfo[count - 1];
- tab.browser.contentWindow.addEventListener("beforeunload", function(event) {
- event.returnValue = "Green llama in your car";
- });
-
- const interactionPref = "dom.require_user_interaction_for_beforeunload";
- Services.prefs.setBoolPref(interactionPref, false);
-
- plan_for_modal_dialog("commonDialogWindow", function(controller) {
- controller.window.document
- .querySelector("dialog")
- .getButton("accept")
- .doCommand();
- });
- mc.tabmail.closeTab(tab);
- wait_for_modal_dialog();
-
- Services.prefs.clearUserPref(interactionPref);
-}
-
-// XXX todo
-// - test find bar
-// - window.close within tab
-// - zoom?
-
-function teardownModule() {
- while (mc.tabmail.tabInfo.length > 1) {
- mc.tabmail.closeTab(1);
- }
-}
deleted file mode 100644
--- a/mail/test/mozmill/content-tabs/test-install-xpi.js
+++ /dev/null
@@ -1,132 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-var controller = ChromeUtils.import(
- "chrome://mozmill/content/modules/controller.jsm"
-);
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-var mozmill = ChromeUtils.import(
- "chrome://mozmill/content/modules/mozmill.jsm"
-);
-
-var { content_tab_eid, open_content_tab_with_url } = ChromeUtils.import(
- "resource://testing-common/mozmill/ContentTabHelpers.jsm"
-);
-var { mc } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-// RELATIVE_ROOT messes with the collector, so we have to bring the path back
-// so we get the right path for the resources.
-var url = collector.addHttpResource("../content-tabs/html", "content-tabs");
-
-var gDocument;
-var gNewTab;
-
-function setupModule(module) {
- gDocument = mc.window.document;
- gNewTab = open_content_tab_with_url(
- url + "installxpi.html",
- "specialTabs.siteClickHandler(event, new RegExp('^" + url + "'));"
- );
-}
-
-var teardownModule = function(module) {
- mc.tabmail.closeTab(gNewTab);
-};
-
-function waitForNotification(id, buttonToClickSelector, callback) {
- let path = `
- /id("messengerWindow")/id("mainPopupSet")/id("notification-popup")/id("${id}-notification")
- `.trim();
- let notification = new elib.Lookup(gDocument, path);
- mc.waitForElement(notification);
- mc.waitFor(() => !gDocument.querySelector(`#${id}-notification`).hidden);
- // Give the UI some time to settle.
- mc.sleep(500);
- if (callback) {
- callback();
- }
- let button = gDocument.querySelector(
- `#${id}-notification ${buttonToClickSelector}`
- );
- mc.click(new elib.Elem(button));
- mc.waitForElementNotPresent(notification);
-}
-
-function test_install_corrupt_xpi() {
- // This install with give us a corrupt xpi warning.
- mc.click(content_tab_eid(gNewTab, "corruptlink"));
- waitForNotification(
- "addon-install-blocked",
- ".popup-notification-primary-button"
- );
- waitForNotification(
- "addon-install-failed",
- ".popup-notification-primary-button"
- );
-}
-
-function test_install_xpi_offer() {
- mc.click(content_tab_eid(gNewTab, "installlink"));
- waitForNotification(
- "addon-install-blocked",
- ".popup-notification-primary-button"
- );
- waitForNotification(
- "addon-install-failed",
- ".popup-notification-primary-button"
- );
-}
-
-function test_xpinstall_disabled() {
- Services.prefs.setBoolPref("xpinstall.enabled", false);
-
- // Try installation again - this time we'll get an install has been disabled message.
- mc.click(content_tab_eid(gNewTab, "installlink"));
- waitForNotification(
- "xpinstall-disabled",
- ".popup-notification-secondary-button"
- );
-
- Services.prefs.clearUserPref("xpinstall.enabled");
-}
-
-function test_xpinstall_actually_install() {
- mc.click(content_tab_eid(gNewTab, "installlink"));
- waitForNotification(
- "addon-install-blocked",
- ".popup-notification-primary-button"
- );
- waitForNotification(
- "addon-install-failed",
- ".popup-notification-primary-button"
- );
-}
-
-function test_xpinstall_webext_actually_install() {
- mc.click(content_tab_eid(gNewTab, "installwebextlink"));
- waitForNotification(
- "addon-install-blocked",
- ".popup-notification-primary-button"
- );
- waitForNotification(
- "addon-webext-permissions",
- ".popup-notification-primary-button",
- () => {
- let intro = new elib.ID(gDocument, "addon-webext-perm-intro");
- mc.assertNotDOMProperty(intro, "hidden", "true");
- let permissionList = new elib.ID(gDocument, "addon-webext-perm-list");
- mc.assertNotDOMProperty(permissionList, "hidden", "true");
- mc.assert(() => permissionList.getNode().childElementCount == 1);
- }
- );
- waitForNotification("addon-installed", ".popup-notification-primary-button");
-}
deleted file mode 100644
--- a/mail/test/mozmill/content-tabs/wrapper.py
+++ /dev/null
@@ -1,8 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-PREFS = {
- "extensions.blocklist.url": "http://localhost:43336/dummy.xml",
- "plugin.load_flash_only": False,
-}
deleted file mode 100644
--- a/mail/test/mozmill/cookies/html/cookietest1.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<html>
- <head>
- <title>Cookie Test</title>
- <script>
- document.cookie = "name=CookieTest";
- </script>
- </head>
- <body bgcolor="#FFFFFF">
- <div align="center">
- <h1>Cookie Test</h1>
- </div>
- </body>
-</html>
deleted file mode 100644
--- a/mail/test/mozmill/cookies/html/cookietest2.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<html>
- <head>
- <title>Cookie Test 2</title>
- </head>
- <body bgcolor="#FFFFFF">
- <script>
- var theCookie = document.cookie;
- </script>
- <div align="center">
- <h1>Cookie Test Result</h1>
- </div>
- </body>
-</html>
deleted file mode 100644
--- a/mail/test/mozmill/cookies/test-cookies.js
+++ /dev/null
@@ -1,53 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Test file to check that cookies are correctly enabled in Thunderbird.
- *
- * XXX: Still need to check remote content in messages.
- */
-
-"use strict";
-
-var { open_content_tab_with_url } = ChromeUtils.import(
- "resource://testing-common/mozmill/ContentTabHelpers.jsm"
-);
-var { mc } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-// RELATIVE_ROOT messes with the collector, so we have to bring the path back
-// so we get the right path for the resources.
-var url = collector.addHttpResource("../cookies/html", "cookies");
-
-/**
- * Test deleting junk messages with no messages marked as junk.
- */
-function test_load_cookie_page() {
- open_content_tab_with_url(url + "cookietest1.html");
-}
-
-function test_load_cookie_result_page() {
- open_content_tab_with_url(url + "cookietest2.html");
-
- if (mc.window.content.document.title != "Cookie Test 2") {
- throw new Error(
- "The cookie test 2 page is not the selected tab or not content-primary"
- );
- }
-
- let cookie = mc.window.content.wrappedJSObject.theCookie;
-
- dump("Cookie is: " + cookie + "\n");
-
- if (!cookie) {
- throw new Error("Document has no cookie :-(");
- }
-
- if (cookie != "name=CookieTest") {
- throw new Error(
- "Cookie set incorrectly, expected: name=CookieTest, got: " + cookie + "\n"
- );
- }
-}
deleted file mode 100644
--- a/mail/test/mozmill/downloads/test-about-downloads.js
+++ /dev/null
@@ -1,351 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Test about:downloads.
- */
-
-"use strict";
-
-var elementslib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-
-var { gMockFilePicker, gMockFilePickReg } = ChromeUtils.import(
- "resource://testing-common/mozmill/AttachmentHelpers.jsm"
-);
-var { content_tab_e, content_tab_eid } = ChromeUtils.import(
- "resource://testing-common/mozmill/ContentTabHelpers.jsm"
-);
-var {
- assert_equals,
- assert_false,
- assert_not_equals,
- be_in_folder,
- close_tab,
- create_folder,
- make_new_sets_in_folder,
- mc,
- select_click_row,
- switch_tab,
- wait_for_popup_to_open,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { wait_for_browser_load } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var downloads = ChromeUtils.import("resource://gre/modules/Downloads.jsm");
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var downloadsTab;
-
-var attachmentFileNames = [
- "Attachment#1.txt",
- "Attachment#2.txt",
- "Attachment#3.txt",
-];
-
-var downloadsView = {
- init() {
- this.items = new Map();
- this.removedItems = [];
- },
-
- get count() {
- return this.items.size;
- },
-
- onDownloadAdded(aDownload) {
- this.items.set(aDownload, aDownload.target.path);
- },
-
- onDownloadChanged(aDownload) {},
-
- onDownloadRemoved(aDownload) {
- this.removedItems.push(aDownload.target.path);
- this.items.delete(aDownload);
- },
-
- waitForFinish() {
- let succeededPromises = [];
- for (let download of this.items.keys()) {
- let succeededPromise = download.whenSucceeded();
- succeededPromises.push(succeededPromise);
- }
- let finished = false;
- Promise.all(succeededPromises).then(
- () => (finished = true),
- Cu.reportError
- );
- mc.waitFor(() => finished, "Timeout waiting for downloads to complete.");
- },
-};
-
-function prepare_messages() {
- let folder = create_folder("about:downloads");
- make_new_sets_in_folder(folder, [
- {
- count: 1,
- attachments: [
- {
- filename: attachmentFileNames[0],
- body: "Body",
- },
- ],
- },
- {
- count: 1,
- attachments: [
- {
- filename: attachmentFileNames[1],
- body: "Body",
- },
- ],
- },
- {
- count: 1,
- attachments: [
- {
- filename: attachmentFileNames[2],
- body: "Body",
- },
- ],
- },
- ]);
- be_in_folder(folder);
-}
-
-function prepare_downloads_view() {
- let success = false;
- downloads.Downloads.getList(downloads.Downloads.ALL)
- .then(list => list.addView(downloadsView))
- .then(() => (success = true), Cu.reportError);
- mc.waitFor(() => success, "Timeout waiting for attaching our download view.");
-}
-
-function setupModule(module) {
- gMockFilePickReg.register();
-
- prepare_messages();
- prepare_downloads_view();
-
- downloadsTab = open_about_downloads();
-}
-
-function setupTest(test) {
- downloadsView.init();
-}
-
-function open_about_downloads() {
- let preCount = mc.tabmail.tabContainer.allTabs.length;
- let newTab = mc.tabmail.openTab("chromeTab", {
- chromePage: "about:downloads",
- clickHandler: "specialTabs.aboutClickHandler(event);",
- });
- mc.waitFor(
- () => mc.tabmail.tabContainer.allTabs.length == preCount + 1,
- "Timeout waiting for about:downloads tab"
- );
-
- wait_for_browser_load(newTab.browser, "about:downloads");
- // We append new tabs at the end, so check the last one.
- let expectedNewTab = mc.tabmail.tabInfo[preCount];
- return expectedNewTab;
-}
-
-/**
- * Test that there is no file in the list at first.
- */
-function test_empty_list() {
- switch_tab(downloadsTab);
-
- let empty = content_tab_e(downloadsTab, "msgDownloadsListEmptyDescription");
- assert_false(empty.hidden, "msgDownloadsListEmptyDescription is not visible");
-}
-
-function save_attachment_files() {
- switch_tab(0);
-
- let profileDir = Services.dirsvc.get("ProfD", Ci.nsIFile);
-
- let length = attachmentFileNames.length;
- for (let i = 0; i < length; i++) {
- let file = profileDir.clone();
- file.append(attachmentFileNames[i]);
- select_click_row(i);
- gMockFilePicker.returnFiles = [file];
- mc.click(
- mc.eid("attachmentSaveAllSingle", {
- class: "toolbarbutton-menubutton-button",
- })
- );
- }
-}
-
-/**
- * Test that all downloaded files are showed up in the list.
- */
-function test_save_attachment_files_in_list() {
- save_attachment_files();
-
- mc.tabmail.switchToTab(downloadsTab);
- let list = content_tab_e(downloadsTab, "msgDownloadsRichListBox");
-
- let length = attachmentFileNames.length;
- mc.waitFor(
- () => downloadsView.count == length,
- () =>
- "Timeout waiting for saving three attachment files; " +
- "downloadsView.count=" +
- downloadsView.count
- );
-
- assert_equals(length, list.children.length);
- assert_equals(downloadsView.count, list.children.length);
-
- let actualNames = [];
- let child = list.firstElementChild;
- dump(child.querySelector(".fileName").getAttribute("value"));
- while (child) {
- actualNames.push(child.querySelector(".fileName").getAttribute("value"));
- child = child.nextElementSibling;
- }
- actualNames.sort();
-
- for (let i = 0; i < length; i++) {
- assert_equals(attachmentFileNames[i], actualNames[i]);
- }
-}
-
-/**
- * Test that 'remove' in context menu removes surely the target file from
- * the list.
- */
-function test_remove_file() {
- test_save_attachment_files_in_list();
-
- let list = content_tab_e(downloadsTab, "msgDownloadsRichListBox");
- let firstElement = list.firstElementChild;
- let removingFileName = firstElement
- .querySelector(".fileName")
- .getAttribute("value");
-
- // select first element
- mc.click(new elementslib.Elem(firstElement));
- mc.rightClick(new elementslib.Elem(firstElement));
-
- let contextMenu = content_tab_e(downloadsTab, "msgDownloadsContextMenu");
- wait_for_popup_to_open(contextMenu);
- mc.click_menus_in_sequence(contextMenu, [
- { command: "msgDownloadsCmd_remove" },
- ]);
- mc.waitFor(
- () => downloadsView.count == 2,
- "Timeout waiting for removing a saved attachment file."
- );
-
- let child = list.firstElementChild;
- while (child) {
- assert_not_equals(
- removingFileName,
- child.querySelector(".fileName").getAttribute("value")
- );
- child = child.nextElementSibling;
- }
-}
-
-/**
- * Test that removing multiple files surely removes the files.
- */
-function test_remove_multiple_files() {
- test_save_attachment_files_in_list();
-
- let list = content_tab_e(downloadsTab, "msgDownloadsRichListBox");
- let firstElement = list.firstElementChild.nextElementSibling;
- let secondElement = firstElement.nextElementSibling;
- let removingFileNames = [];
-
- removingFileNames.push(
- firstElement.querySelector(".fileName").getAttribute("value")
- );
- removingFileNames.push(
- secondElement.querySelector(".fileName").getAttribute("value")
- );
-
- // select two elements
- mc.click(new elementslib.Elem(firstElement));
- list.selectItemRange(firstElement, secondElement);
- mc.rightClick(new elementslib.Elem(firstElement));
-
- let contextMenu = content_tab_e(downloadsTab, "msgDownloadsContextMenu");
- wait_for_popup_to_open(contextMenu);
- mc.click_menus_in_sequence(contextMenu, [
- { command: "msgDownloadsCmd_remove" },
- ]);
- mc.waitFor(
- () => downloadsView.count == 1,
- "Timeout waiting for removing two saved attachment files."
- );
-
- let child = list.firstElementChild;
- while (child) {
- for (let name of removingFileNames) {
- assert_not_equals(
- name,
- child.querySelector(".fileName").getAttribute("value")
- );
- }
- child = child.nextElementSibling;
- }
-}
-
-/**
- * Test that 'clearDownloads" in context menu purges all files in the list.
- */
-function test_clear_all_files() {
- test_save_attachment_files_in_list();
- downloadsView.waitForFinish();
-
- mc.click(content_tab_eid(downloadsTab, "msgDownloadsRichListBox"));
- mc.rightClick(content_tab_eid(downloadsTab, "msgDownloadsRichListBox"));
-
- let contextMenu = content_tab_e(downloadsTab, "msgDownloadsContextMenu");
- wait_for_popup_to_open(contextMenu);
- mc.click_menus_in_sequence(contextMenu, [
- { command: "msgDownloadsCmd_clearDownloads" },
- ]);
- mc.waitFor(
- () => downloadsView.count == 0,
- "Timeout waiting for clearing all saved attachment files."
- );
-
- let empty = content_tab_e(downloadsTab, "msgDownloadsListEmptyDescription");
- assert_false(empty.hidden, "msgDownloadsListEmptyDescription is not visible");
-}
-
-function teardownTest() {
- downloads.Downloads.getList(downloads.Downloads.ALL)
- .then(function(list) {
- for (let download of downloadsView.items.keys()) {
- list.remove(download);
- }
- })
- .then(null, Cu.reportError);
- mc.waitFor(
- () => downloadsView.count == 0,
- "Timeout waiting for clearing all saved attachment files."
- );
- let empty = content_tab_e(downloadsTab, "msgDownloadsListEmptyDescription");
- mc.waitFor(
- () => empty.hidden === false,
- "Timeout waiting for msgDownloadsListEmptyDescription is visible."
- );
-}
-
-function teardownModule(module) {
- close_tab(downloadsTab);
- gMockFilePickReg.unregister();
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-display/test-archive-messages.js
+++ /dev/null
@@ -1,115 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-var {
- add_sets_to_folders,
- archive_messages,
- assert_message_not_in_view,
- assert_nothing_selected,
- assert_selected,
- assert_selected_and_displayed,
- be_in_folder,
- create_folder,
- create_thread,
- make_display_threaded,
- mc,
- select_click_row,
- select_none,
- select_shift_click_row,
- toggle_thread_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var folder;
-
-/**
- * The number of messages in the thread we use to test.
- */
-var NUM_MESSAGES_IN_THREAD = 6;
-
-function setupModule(module) {
- folder = create_folder("ThreadedMessages");
- let thread = create_thread(NUM_MESSAGES_IN_THREAD);
- add_sets_to_folders([folder], [thread]);
- thread = create_thread(NUM_MESSAGES_IN_THREAD);
- add_sets_to_folders([folder], [thread]);
-}
-
-/**
- * Test archiving messages that are not currently selected.
- */
-function test_batch_archiver() {
- be_in_folder(folder);
- make_display_threaded();
-
- select_none();
- assert_nothing_selected();
-
- /* Select the first (expanded) thread */
- let root = select_click_row(0);
- assert_selected_and_displayed(root);
-
- /* Get a grip on the first and the second sub-message */
- let m1 = select_click_row(1);
- let m2 = select_click_row(2);
- select_click_row(0);
- assert_selected_and_displayed(root);
-
- /* The root message is selected, we archive the first sub-message */
- archive_messages([m1]);
-
- /* This message is gone and the root message is still selected **/
- assert_message_not_in_view([m1]);
- assert_selected_and_displayed(root);
-
- /* Now, archiving messages under a collapsed thread */
- toggle_thread_row(0);
- archive_messages([m2]);
-
- /* Selection didn't change */
- assert_selected(root);
-
- /* And the message is gone */
- toggle_thread_row(0);
- assert_message_not_in_view([m2]);
-
- /* Both threads are collapsed */
- toggle_thread_row(0);
- toggle_thread_row(1);
-
- /* Get a grip on the second thread */
- let root2 = select_click_row(1);
- select_click_row(0);
- assert_selected(root);
-
- /* Archive the first thread, now the second thread should be selected */
- archive_messages(mc.folderDisplay.selectedMessages);
- assert_selected(root2);
-
- /* We only have the first thread left */
- toggle_thread_row(0);
- assert_selected_and_displayed(root2);
-
- /* Archive the head of the thread, check that it still works fine */
- let child1 = select_click_row(1);
- select_click_row(0);
- archive_messages([root2]);
- assert_selected_and_displayed(child1);
-
- /* Test archiving a partial selection */
- let child2 = select_click_row(1);
- let child3 = select_click_row(2);
- select_click_row(3);
-
- select_shift_click_row(2);
- select_shift_click_row(1);
- select_shift_click_row(0);
-
- archive_messages([child1, child3]);
- assert_message_not_in_view([child1, child3]);
- assert_selected_and_displayed(child2);
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-display/test-close-window-on-delete.js
+++ /dev/null
@@ -1,304 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test that the close message window on delete option works.
- */
-
-"use strict";
-
-var {
- assert_number_of_tabs_open,
- be_in_folder,
- close_tab,
- create_folder,
- make_new_sets_in_folder,
- mc,
- open_selected_message_in_new_tab,
- open_selected_message_in_new_window,
- press_delete,
- reset_close_message_on_delete,
- select_click_row,
- set_close_message_on_delete,
- switch_tab,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var {
- close_window,
- plan_for_window_close,
- wait_for_window_close,
-} = ChromeUtils.import("resource://testing-common/mozmill/WindowHelpers.jsm");
-
-var folder;
-
-function setupModule(module) {
- folder = create_folder("CloseWindowOnDeleteA");
-
- make_new_sets_in_folder(folder, [{ count: 10 }]);
-}
-
-/**
- * Delete a message and check that the message window is closed
- * where appropriate.
- */
-function test_close_message_window_on_delete_from_message_window() {
- set_close_message_on_delete(true);
- be_in_folder(folder);
-
- // select the first message
- select_click_row(0);
- // display it
- let msgc = open_selected_message_in_new_window();
-
- select_click_row(1);
- let msgc2 = open_selected_message_in_new_window();
-
- let preCount = folder.getTotalMessages(false);
- msgc.window.focus();
- plan_for_window_close(msgc);
- press_delete(msgc);
- if (folder.getTotalMessages(false) != preCount - 1) {
- throw new Error("didn't delete a message before closing window");
- }
- wait_for_window_close(msgc);
-
- if (msgc2.window.closed) {
- throw new Error("should only have closed the active window");
- }
-
- close_window(msgc2);
-
- reset_close_message_on_delete();
-}
-
-/**
- * Delete a message when multiple windows are open to the message, and the
- * message is deleted from one of them.
- */
-function test_close_multiple_message_windows_on_delete_from_message_window() {
- set_close_message_on_delete(true);
- be_in_folder(folder);
-
- // select the first message
- select_click_row(0);
- // display it
- let msgc = open_selected_message_in_new_window();
- let msgcA = open_selected_message_in_new_window();
-
- select_click_row(1);
- let msgc2 = open_selected_message_in_new_window();
-
- let preCount = folder.getTotalMessages(false);
- msgc.window.focus();
- plan_for_window_close(msgc);
- plan_for_window_close(msgcA);
- press_delete(msgc);
-
- if (folder.getTotalMessages(false) != preCount - 1) {
- throw new Error("didn't delete a message before closing window");
- }
- wait_for_window_close(msgc);
- wait_for_window_close(msgcA);
-
- if (msgc2.window.closed) {
- throw new Error("should only have closed the active window");
- }
-
- close_window(msgc2);
-
- reset_close_message_on_delete();
-}
-
-/**
- * Delete a message when multiple windows are open to the message, and the
- * message is deleted from the 3-pane window.
- */
-function test_close_multiple_message_windows_on_delete_from_3pane_window() {
- set_close_message_on_delete(true);
- be_in_folder(folder);
-
- // select the first message
- select_click_row(0);
- // display it
- let msgc = open_selected_message_in_new_window();
- let msgcA = open_selected_message_in_new_window();
-
- select_click_row(1);
- let msgc2 = open_selected_message_in_new_window();
-
- let preCount = folder.getTotalMessages(false);
- mc.window.focus();
- plan_for_window_close(msgc);
- plan_for_window_close(msgcA);
- select_click_row(0);
- press_delete(mc);
-
- if (folder.getTotalMessages(false) != preCount - 1) {
- throw new Error("didn't delete a message before closing window");
- }
- wait_for_window_close(msgc);
- wait_for_window_close(msgcA);
-
- if (msgc2.window.closed) {
- throw new Error("should only have closed the first window");
- }
-
- close_window(msgc2);
-
- reset_close_message_on_delete();
-}
-
-/**
- * Delete a message and check that the message tab is closed
- * where appropriate.
- */
-function test_close_message_tab_on_delete_from_message_tab() {
- set_close_message_on_delete(true);
- be_in_folder(folder);
-
- // select the first message
- select_click_row(0);
- // display it
- let msgc = open_selected_message_in_new_tab(true);
-
- select_click_row(1);
- let msgc2 = open_selected_message_in_new_tab(true);
-
- let preCount = folder.getTotalMessages(false);
- switch_tab(msgc);
- press_delete();
-
- if (folder.getTotalMessages(false) != preCount - 1) {
- throw new Error("didn't delete a message before closing tab");
- }
-
- assert_number_of_tabs_open(2);
-
- if (msgc2 != mc.tabmail.tabInfo[1]) {
- throw new Error("should only have closed the active tab");
- }
-
- close_tab(msgc2);
-
- reset_close_message_on_delete();
-}
-
-/**
- * Delete a message when multiple windows are open to the message, and the
- * message is deleted from one of them.
- */
-function test_close_multiple_message_tabs_on_delete_from_message_tab() {
- set_close_message_on_delete(true);
- be_in_folder(folder);
-
- // select the first message
- select_click_row(0);
- // display it
- let msgc = open_selected_message_in_new_tab(true);
- open_selected_message_in_new_tab(true);
-
- select_click_row(1);
- let msgc2 = open_selected_message_in_new_tab(true);
-
- let preCount = folder.getTotalMessages(false);
- switch_tab(msgc);
- press_delete();
-
- if (folder.getTotalMessages(false) != preCount - 1) {
- throw new Error("didn't delete a message before closing tab");
- }
-
- assert_number_of_tabs_open(2);
-
- if (msgc2 != mc.tabmail.tabInfo[1]) {
- throw new Error("should only have closed the active tab");
- }
-
- close_tab(msgc2);
-
- reset_close_message_on_delete();
-}
-
-/**
- * Delete a message when multiple tabs are open to the message, and the
- * message is deleted from the 3-pane window.
- */
-function test_close_multiple_message_tabs_on_delete_from_3pane_window() {
- set_close_message_on_delete(true);
- be_in_folder(folder);
-
- // select the first message
- select_click_row(0);
- // display it
- open_selected_message_in_new_tab(true);
- open_selected_message_in_new_tab(true);
-
- select_click_row(1);
- let msgc2 = open_selected_message_in_new_tab(true);
-
- let preCount = folder.getTotalMessages(false);
- mc.window.focus();
- select_click_row(0);
- press_delete(mc);
-
- if (folder.getTotalMessages(false) != preCount - 1) {
- throw new Error("didn't delete a message before closing window");
- }
-
- assert_number_of_tabs_open(2);
-
- if (msgc2 != mc.tabmail.tabInfo[1]) {
- throw new Error("should only have closed the active tab");
- }
-
- close_tab(msgc2);
-
- reset_close_message_on_delete();
-}
-
-/**
- * Delete a message when multiple windows and tabs are open to the message, and
- * the message is deleted from the 3-pane window.
- */
-function test_close_multiple_windows_tabs_on_delete_from_3pane_window() {
- set_close_message_on_delete(true);
- be_in_folder(folder);
-
- // select the first message
- select_click_row(0);
- // display it
- open_selected_message_in_new_tab(true);
- let msgcA = open_selected_message_in_new_window();
-
- select_click_row(1);
- let msgc2 = open_selected_message_in_new_tab(true);
- let msgc2A = open_selected_message_in_new_window();
-
- let preCount = folder.getTotalMessages(false);
- mc.window.focus();
- plan_for_window_close(msgcA);
- select_click_row(0);
- press_delete(mc);
-
- if (folder.getTotalMessages(false) != preCount - 1) {
- throw new Error("didn't delete a message before closing window");
- }
- wait_for_window_close(msgcA);
-
- assert_number_of_tabs_open(2);
-
- if (msgc2 != mc.tabmail.tabInfo[1]) {
- throw new Error("should only have closed the active tab");
- }
-
- if (msgc2A.window.closed) {
- throw new Error("should only have closed the first window");
- }
-
- close_tab(msgc2);
- close_window(msgc2A);
-
- reset_close_message_on_delete();
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-display/test-columns.js
+++ /dev/null
@@ -1,677 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test column default logic and persistence logic. Persistence comes in both
- * tab-switching (because of the multiplexed implementation) and
- * folder-switching forms.
- */
-
-"use strict";
-
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-
-var {
- be_in_folder,
- close_tab,
- create_folder,
- create_virtual_folder,
- enter_folder,
- inboxFolder,
- mc,
- open_folder_in_new_tab,
- switch_tab,
- wait_for_all_messages_to_load,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var {
- plan_for_modal_dialog,
- plan_for_observable_event,
- wait_for_modal_dialog,
- wait_for_observable_event,
-} = ChromeUtils.import("resource://testing-common/mozmill/WindowHelpers.jsm");
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-// needed to zero inter-folder processing delay
-var { MailUtils } = ChromeUtils.import("resource:///modules/MailUtils.jsm");
-
-var folderInbox, folderSent, folderVirtual, folderA, folderB;
-// INBOX_DEFAULTS sans 'dateCol' but gains 'tagsCol'
-var columnsB;
-// GLODA_DEFAULTS sans 'locationCol' but gains 'accountCol'
-var glodaColumns;
-
-// these are for the reset/apply to other/apply to other+child tests.
-var folderSource, folderParent, folderChild1, folderChild2;
-
-var gColumnStateUpdated = false;
-
-var useCorrespondent;
-var INBOX_DEFAULTS;
-var SENT_DEFAULTS;
-var VIRTUAL_DEFAULTS;
-var GLODA_DEFAULTS;
-
-function setupModule(module) {
- useCorrespondent = Services.prefs.getBoolPref(
- "mail.threadpane.use_correspondents"
- );
- INBOX_DEFAULTS = [
- "threadCol",
- "flaggedCol",
- "attachmentCol",
- "subjectCol",
- "unreadButtonColHeader",
- useCorrespondent ? "correspondentCol" : "senderCol",
- "junkStatusCol",
- "dateCol",
- ];
- SENT_DEFAULTS = [
- "threadCol",
- "flaggedCol",
- "attachmentCol",
- "subjectCol",
- "unreadButtonColHeader",
- useCorrespondent ? "correspondentCol" : "recipientCol",
- "junkStatusCol",
- "dateCol",
- ];
- VIRTUAL_DEFAULTS = [
- "threadCol",
- "flaggedCol",
- "attachmentCol",
- "subjectCol",
- "unreadButtonColHeader",
- useCorrespondent ? "correspondentCol" : "senderCol",
- "junkStatusCol",
- "dateCol",
- "locationCol",
- ];
- GLODA_DEFAULTS = [
- "threadCol",
- "flaggedCol",
- "subjectCol",
- useCorrespondent ? "correspondentCol" : "senderCol",
- "dateCol",
- "locationCol",
- ];
-
- // create the source
- folderSource = create_folder("ColumnsApplySource");
-}
-
-/**
- * Get the currently visible threadTree columns.
- */
-function get_visible_threadtree_columns() {
- let cols = mc.e("threadTree").columns;
- let visibleColumnIds = [];
- for (let col = cols.getFirstColumn(); col != null; col = col.getNext()) {
- if (col.element.getAttribute("hidden") != "true") {
- visibleColumnIds.push(col.id);
- }
- }
- return visibleColumnIds;
-}
-
-/**
- * Verify that the provided list of columns is visible in the given order,
- * throwing an exception if it is not the case.
- *
- * @param aDesiredColumns A list of column ID strings for columns that should be
- * visible in the order that they should be visible.
- */
-function assert_visible_columns(aDesiredColumns) {
- let cols = mc.e("threadTree").columns;
- let iDesired = 0;
-
- let visibleColumnIds = [];
- let failCol = null;
- for (let col = cols.getFirstColumn(); col != null; col = col.getNext()) {
- if (col.element.getAttribute("hidden") != "true") {
- visibleColumnIds.push(col.id);
- if (!failCol) {
- if (aDesiredColumns[iDesired] != col.id) {
- failCol = col;
- } else {
- iDesired++;
- }
- }
- }
- }
- if (failCol) {
- throw new Error(
- "Found visible column '" +
- failCol.id +
- "' but was " +
- "expecting '" +
- aDesiredColumns[iDesired] +
- "'!" +
- "\ndesired list: " +
- aDesiredColumns +
- "\n actual list: " +
- visibleColumnIds
- );
- }
-}
-
-/**
- * Show the column with the given id.
- *
- * @param aColumnId Id of the treecol element you want to show.
- */
-function show_column(aColumnId) {
- mc.e(aColumnId).removeAttribute("hidden");
-}
-
-/**
- * Hide the column with the given id.
- *
- * @param aColumnId Id of the treecol element you want to hide.
- */
-function hide_column(aColumnId) {
- mc.e(aColumnId).setAttribute("hidden", "true");
-}
-
-/**
- * Move a column before another column.
- *
- * @param aColumnId The id of the column you want to move.
- * @param aBeforeId The id of the column you want the moving column to end up
- * before.
- */
-function reorder_column(aColumnId, aBeforeId) {
- let col = mc.e(aColumnId);
- let before = mc.e(aBeforeId);
- mc.threadTree._reorderColumn(col, before, true);
-}
-
-/**
- * Make sure we set the proper defaults for an Inbox.
- */
-function test_column_defaults_inbox() {
- // just use the inbox; comes from test-folder-display-helpers
- folderInbox = inboxFolder;
- enter_folder(folderInbox);
- assert_visible_columns(INBOX_DEFAULTS);
-}
-
-/**
- * Make sure we set the proper defaults for a Sent folder.
- */
-function test_column_defaults_sent() {
- folderSent = create_folder("ColumnsSent");
- folderSent.setFlag(Ci.nsMsgFolderFlags.SentMail);
-
- be_in_folder(folderSent);
- assert_visible_columns(SENT_DEFAULTS);
-}
-
-/**
- * Make sure we set the proper defaults for a multi-folder virtual folder.
- */
-function test_column_defaults_cross_folder_virtual_folder() {
- folderVirtual = create_virtual_folder(
- [folderInbox, folderSent],
- {},
- true,
- "ColumnsVirtual"
- );
-
- be_in_folder(folderVirtual);
- assert_visible_columns(VIRTUAL_DEFAULTS);
-}
-
-/**
- * Make sure that we initialize our columns from the inbox and that they persist
- * after that and don't follow the inbox. This also does a good workout of the
- * persistence logic.
- */
-function test_column_defaults_inherit_from_inbox() {
- folderA = create_folder("ColumnsA");
- // - the folder should inherit from the inbox...
- be_in_folder(folderA);
- assert_visible_columns(INBOX_DEFAULTS);
-
- // - if we go back to the inbox and change things then the folder's settings
- // should not change.
- be_in_folder(folderInbox);
- // show tags, hide date
- hide_column("dateCol");
- show_column("tagsCol");
- // (paranoia verify)
- columnsB = INBOX_DEFAULTS.slice(0, -1);
- columnsB.push("tagsCol");
- assert_visible_columns(columnsB);
-
- // make sure A did not change; it should still have dateCol.
- be_in_folder(folderA);
- assert_visible_columns(INBOX_DEFAULTS);
-
- // - but folder B should pick up on the modified set
- folderB = create_folder("ColumnsB");
- be_in_folder(folderB);
- assert_visible_columns(columnsB);
-
- // - and if we restore the inbox, folder B should stay modified too.
- be_in_folder(folderInbox);
- show_column("dateCol");
- hide_column("tagsCol");
- assert_visible_columns(INBOX_DEFAULTS);
-
- be_in_folder(folderB);
- assert_visible_columns(columnsB);
-}
-
-/**
- * Make sure that when we change tabs that things persist/restore correctly.
- */
-function test_column_visibility_persists_through_tab_changes() {
- let tabA = be_in_folder(folderA);
- assert_visible_columns(INBOX_DEFAULTS);
-
- let tabB = open_folder_in_new_tab(folderB);
- assert_visible_columns(columnsB);
-
- // - switch back and forth among the loaded and verify
- switch_tab(tabA);
- assert_visible_columns(INBOX_DEFAULTS);
-
- switch_tab(tabB);
- assert_visible_columns(columnsB);
-
- // - change things and make sure the changes stick
- // B gain accountCol
- let bWithExtra = columnsB.concat(["accountCol"]);
- show_column("accountCol");
- assert_visible_columns(bWithExtra);
-
- switch_tab(tabA);
- assert_visible_columns(INBOX_DEFAULTS);
-
- // A loses junk
- let aSansJunk = INBOX_DEFAULTS.slice(0, -2); // nukes junk, date
- hide_column("junkStatusCol");
- aSansJunk.push("dateCol"); // put date back
- assert_visible_columns(aSansJunk);
-
- switch_tab(tabB);
- assert_visible_columns(bWithExtra);
- // B goes back to normal
- hide_column("accountCol");
-
- switch_tab(tabA);
- assert_visible_columns(aSansJunk);
- // A goes back to "normal"
- show_column("junkStatusCol");
- assert_visible_columns(INBOX_DEFAULTS);
-
- close_tab(tabB);
-}
-
-/**
- * Make sure that when we change folders that things persist/restore correctly.
- */
-function test_column_visibility_persists_through_folder_changes() {
- be_in_folder(folderA);
- assert_visible_columns(INBOX_DEFAULTS);
-
- // more for A
- let aWithExtra = INBOX_DEFAULTS.concat(["sizeCol", "tagsCol"]);
- show_column("sizeCol");
- show_column("tagsCol");
- assert_visible_columns(aWithExtra);
-
- be_in_folder(folderB);
- assert_visible_columns(columnsB);
-
- // B gain accountCol
- let bWithExtra = columnsB.concat(["accountCol"]);
- show_column("accountCol");
- assert_visible_columns(bWithExtra);
-
- // check A
- be_in_folder(folderA);
- assert_visible_columns(aWithExtra);
-
- // check B
- be_in_folder(folderB);
- assert_visible_columns(bWithExtra);
-
- // restore B
- hide_column("accountCol");
-
- // restore A
- be_in_folder(folderA);
- hide_column("sizeCol");
- hide_column("tagsCol");
-
- // check B
- be_in_folder(folderB);
- assert_visible_columns(columnsB);
-
- // check A
- be_in_folder(folderA);
- assert_visible_columns(INBOX_DEFAULTS);
-}
-
-/**
- * Test that reordering persists through tab changes and folder changes.
- */
-function test_column_reordering_persists() {
- let tabA = be_in_folder(folderA);
- let tabB = open_folder_in_new_tab(folderB);
-
- // put correspondent/sender before subject
- reorder_column(
- useCorrespondent ? "correspondentCol" : "senderCol",
- "subjectCol"
- );
- let reorderdB = columnsB.concat();
- reorderdB.splice(5, 1);
- reorderdB.splice(3, 0, useCorrespondent ? "correspondentCol" : "senderCol");
- assert_visible_columns(reorderdB);
-
- switch_tab(tabA);
- assert_visible_columns(INBOX_DEFAULTS);
-
- switch_tab(tabB);
- assert_visible_columns(reorderdB);
-
- be_in_folder(folderInbox);
- assert_visible_columns(INBOX_DEFAULTS);
-
- be_in_folder(folderB);
- assert_visible_columns(reorderdB);
-
- close_tab(tabB);
-}
-
-function invoke_column_picker_option(aActions) {
- // The treecolpicker element itself doesn't have an id, so we have to walk
- // down from the parent to find it.
- // treadCols
- // |- hbox item 0
- // |- treecolpicker <-- item 1 this is the one we want
- let threadCols = mc.window.document.getElementById("threadCols");
- let colPicker = threadCols.querySelector("treecolpicker");
- let colPickerPopup = colPicker.querySelector("[anonid=popup]");
-
- mc.click(new elib.Elem(colPicker));
- mc.click_menus_in_sequence(colPickerPopup, aActions);
-}
-
-/**
- * The column picker's "reset columns to default" option should set our state
- * back to the natural state.
- */
-function test_reset_to_inbox() {
- // it better have INBOX defaults
- assert_visible_columns(INBOX_DEFAULTS);
-
- // permute them
- let conExtra = INBOX_DEFAULTS.concat(["sizeCol"]);
- show_column("sizeCol");
- assert_visible_columns(conExtra);
-
- // reset!
- invoke_column_picker_option([{ anonid: "menuitem" }]);
-}
-
-function subtest_say_yes(cwc) {
- cwc.window.document
- .querySelector("dialog")
- .getButton("accept")
- .doCommand();
-}
-
-function _apply_to_folder_common(aChildrenToo, folder) {
- if (aChildrenToo) {
- plan_for_observable_event("msg-folder-columns-propagated");
- }
- plan_for_modal_dialog("commonDialogWindow", subtest_say_yes);
- invoke_column_picker_option([
- { class: "applyTo-menu" },
- {
- class: aChildrenToo
- ? "applyToFolderAndChildren-menu"
- : "applyToFolder-menu",
- },
- { label: "Local Folders" },
- { label: folder.name },
- { label: folder.name },
- ]);
- wait_for_modal_dialog("commonDialogWindow");
- if (aChildrenToo) {
- wait_for_observable_event("msg-folder-columns-propagated");
- }
-}
-
-/**
- * Change settings in a folder, apply them to another folder that also has
- * children. Make sure the folder changes but the children do not.
- */
-function test_apply_to_folder_no_children() {
- folderParent = create_folder("ColumnsApplyParent");
- folderParent.createSubfolder("Child1", null);
- folderChild1 = folderParent.getChildNamed("Child1");
- folderParent.createSubfolder("Child2", null);
- folderChild2 = folderParent.getChildNamed("Child2");
-
- be_in_folder(folderSource);
-
- // reset!
- invoke_column_picker_option([{ anonid: "menuitem" }]);
-
- // permute!
- let conExtra = INBOX_DEFAULTS.concat(["sizeCol"]);
- show_column("sizeCol");
- assert_visible_columns(conExtra);
-
- // apply to the one dude
- _apply_to_folder_common(false, folderParent);
-
- // make sure it copied to the parent
- be_in_folder(folderParent);
- assert_visible_columns(conExtra);
-
- // but not the children
- be_in_folder(folderChild1);
- assert_visible_columns(INBOX_DEFAULTS);
- be_in_folder(folderChild2);
- assert_visible_columns(INBOX_DEFAULTS);
-}
-
-/**
- * Change settings in a folder, apply them to another folder and its children.
- * Make sure the folder and its children change.
- */
-function test_apply_to_folder_and_children() {
- // no need to throttle ourselves during testing.
- MailUtils.INTER_FOLDER_PROCESSING_DELAY_MS = 0;
-
- be_in_folder(folderSource);
-
- invoke_column_picker_option([{ anonid: "menuitem" }]); // reset order!
- let cols = get_visible_threadtree_columns();
-
- // permute!
- let conExtra = cols.concat(["tagsCol"]);
- show_column("tagsCol");
- assert_visible_columns(conExtra);
-
- // apply to the dude and his offspring
- _apply_to_folder_common(true, folderParent);
-
- // make sure it copied to the parent and his children
- be_in_folder(folderParent);
- assert_visible_columns(conExtra);
- be_in_folder(folderChild1);
- assert_visible_columns(conExtra);
- be_in_folder(folderChild2);
- assert_visible_columns(conExtra);
-}
-
-/**
- * Change settings in an incoming folder, apply them to an outgoing folder that
- * also has children. Make sure the folder changes but the children do not.
- */
-function test_apply_to_folder_no_children_swapped() {
- folderParent = create_folder("ColumnsApplyParentOutgoing");
- folderParent.setFlag(Ci.nsMsgFolderFlags.SentMail);
- folderParent.createSubfolder("Child1", null);
- folderChild1 = folderParent.getChildNamed("Child1");
- folderParent.createSubfolder("Child2", null);
- folderChild2 = folderParent.getChildNamed("Child2");
-
- be_in_folder(folderSource);
-
- invoke_column_picker_option([{ anonid: "menuitem" }]); // reset order!
- // Hide the columns that were added in other tests, since reset now
- // only resets the order.
- hide_column("tagsCol");
- hide_column("sizeCol");
-
- // permute!
- let conExtra = [...INBOX_DEFAULTS];
- if (useCorrespondent) {
- conExtra[5] = "senderCol";
- hide_column("correspondentCol");
- show_column("senderCol");
- } else {
- conExtra[5] = "correspondentCol";
- hide_column("senderCol");
- show_column("correspondentCol");
- }
- assert_visible_columns(conExtra);
-
- // Apply to the one dude.
- _apply_to_folder_common(false, folderParent);
-
- // Make sure it copied to the parent.
- let conExtraSwapped = [...SENT_DEFAULTS];
- conExtraSwapped[5] = useCorrespondent ? "recipientCol" : "correspondentCol";
- be_in_folder(folderParent);
- assert_visible_columns(conExtraSwapped);
-
- // But not the children.
- be_in_folder(folderChild1);
- assert_visible_columns(SENT_DEFAULTS);
- be_in_folder(folderChild2);
- assert_visible_columns(SENT_DEFAULTS);
-}
-
-/**
- * Change settings in an incoming folder, apply them to an outgoing folder and
- * its children. Make sure the folder and its children change.
- */
-function test_apply_to_folder_and_children_swapped() {
- // No need to throttle ourselves during testing.
- MailUtils.INTER_FOLDER_PROCESSING_DELAY_MS = 0;
-
- be_in_folder(folderSource);
-
- invoke_column_picker_option([{ anonid: "menuitem" }]); // reset order!
-
- // permute!
- let conExtra = [...INBOX_DEFAULTS];
- if (useCorrespondent) {
- conExtra[5] = "senderCol";
- hide_column("correspondentCol");
- show_column("senderCol");
- } else {
- conExtra[5] = "correspondentCol";
- hide_column("senderCol");
- show_column("correspondentCol");
- }
- assert_visible_columns(conExtra);
-
- // Apply to the dude and his offspring.
- _apply_to_folder_common(true, folderParent);
-
- // Make sure it copied to the parent and his children.
- let conExtraSwapped = [...SENT_DEFAULTS];
- conExtraSwapped[5] = useCorrespondent ? "recipientCol" : "correspondentCol";
- be_in_folder(folderParent);
- assert_visible_columns(conExtraSwapped);
- be_in_folder(folderChild1);
- assert_visible_columns(conExtraSwapped);
- be_in_folder(folderChild2);
- assert_visible_columns(conExtraSwapped);
-}
-
-/**
- * Create a fake gloda collection.
- */
-function FakeCollection() {
- this.items = [];
-}
-
-function plan_for_columns_state_update() {
- gColumnStateUpdated = false;
-}
-
-function wait_for_columns_state_updated() {
- const STATE_PREF = "mailnews.database.global.views.global";
- let columns_state_updated = function() {
- gColumnStateUpdated = true;
- };
- Services.prefs.addObserver(STATE_PREF, columns_state_updated);
- mc.waitFor(
- () => gColumnStateUpdated,
- "Timeout waiting for columns state updated."
- );
- Services.prefs.removeObserver(STATE_PREF, columns_state_updated);
-}
-
-function test_column_defaults_gloda_collection() {
- let fakeCollection = new FakeCollection();
- mc.tabmail.openTab("glodaList", { collection: fakeCollection });
- wait_for_all_messages_to_load();
- assert_visible_columns(GLODA_DEFAULTS);
-}
-
-function test_persist_columns_gloda_collection() {
- let fakeCollection = new FakeCollection();
- mc.tabmail.openTab("glodaList", { collection: fakeCollection });
- wait_for_all_messages_to_load();
-
- plan_for_columns_state_update();
- hide_column("locationCol");
- wait_for_columns_state_updated();
-
- plan_for_columns_state_update();
- show_column("accountCol");
- wait_for_columns_state_updated();
-
- glodaColumns = GLODA_DEFAULTS.slice(0, -1);
- glodaColumns.push("accountCol");
-
- mc.tabmail.openTab("glodaList", { collection: fakeCollection });
- wait_for_all_messages_to_load();
- assert_visible_columns(glodaColumns);
-}
-
-function test_reset_columns_gloda_collection() {
- let fakeCollection = new FakeCollection();
- mc.tabmail.openTab("glodaList", { collection: fakeCollection });
- wait_for_all_messages_to_load();
- assert_visible_columns(glodaColumns);
-
- invoke_column_picker_option([{ anonid: "menuitem" }]); // reset!
- assert_visible_columns(glodaColumns); // same, only order (would be) reset
-
- mc.tabmail.openTab("glodaList", { collection: fakeCollection });
- wait_for_all_messages_to_load();
- assert_visible_columns(glodaColumns);
-}
-
-function teardownModule() {
- while (mc.tabmail.tabInfo.length > 1) {
- mc.tabmail.closeTab(1);
- }
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-display/test-deletion-from-virtual-folders.js
+++ /dev/null
@@ -1,348 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test that deleting messages works from a virtual folder.
- */
-
-"use strict";
-
-var {
- assert_messages_in_view,
- assert_selected_and_displayed,
- assert_tab_titled_from,
- be_in_folder,
- create_folder,
- get_smart_folder_named,
- inboxFolder,
- make_new_sets_in_folder,
- mc,
- open_selected_message_in_new_tab,
- open_selected_message_in_new_window,
- press_delete,
- select_click_row,
- switch_tab,
- wait_for_all_messages_to_load,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var {
- plan_for_modal_dialog,
- plan_for_window_close,
- wait_for_modal_dialog,
- wait_for_window_close,
-} = ChromeUtils.import("resource://testing-common/mozmill/WindowHelpers.jsm");
-
-var { MailViewConstants } = ChromeUtils.import(
- "resource:///modules/MailViewManager.jsm"
-);
-
-var baseFolder, folder, lastMessageFolder;
-
-var tabFolder, tabMessage, tabMessageBackground, curMessage, nextMessage;
-
-var setNormal;
-
-/**
- * The message window controller.
- */
-var msgc;
-
-function setupModule(module) {
- baseFolder = create_folder("DeletionFromVirtualFoldersA");
- // For setTagged, we want exactly as many messages as we plan to delete, so
- // that we can test that the message window and tabs close when they run out
- // of things to display.
- let [, setTagged] = make_new_sets_in_folder(baseFolder, [
- { count: 4 },
- { count: 4 },
- ]);
- setTagged.addTag("$label1"); // Important, by default
- // We depend on the count for this, too
- [setNormal] = make_new_sets_in_folder(inboxFolder, [{ count: 4 }]);
-
- // Add the view picker to the toolbar
- let toolbar = mc.e("mail-bar3");
- toolbar.insertItem("mailviews-container", null);
- mc.assertNode(mc.eid("mailviews-container"));
-}
-
-// Check whether this message is displayed in the folder tab
-var VERIFY_FOLDER_TAB = 0x1;
-// Check whether this message is displayed in the foreground message tab
-var VERIFY_MESSAGE_TAB = 0x2;
-// Check whether this message is displayed in the background message tab
-var VERIFY_BACKGROUND_MESSAGE_TAB = 0x4;
-// Check whether this message is displayed in the message window
-var VERIFY_MESSAGE_WINDOW = 0x8;
-var VERIFY_ALL = 0xf;
-
-/**
- * Verify that the message is displayed in the given tabs. The index is
- * optional.
- */
-function _verify_message_is_displayed_in(aFlags, aMessage, aIndex) {
- if (aFlags & VERIFY_FOLDER_TAB) {
- switch_tab(tabFolder);
- assert_selected_and_displayed(aMessage);
- if (aIndex !== undefined) {
- assert_selected_and_displayed(aIndex);
- }
- }
- if (aFlags & VERIFY_MESSAGE_TAB) {
- // Verify the title first
- assert_tab_titled_from(tabMessage, aMessage);
- switch_tab(tabMessage);
- // Verify the title again, just in case
- assert_tab_titled_from(tabMessage, aMessage);
- assert_selected_and_displayed(aMessage);
- if (aIndex !== undefined) {
- assert_selected_and_displayed(aIndex);
- }
- }
- if (aFlags & VERIFY_BACKGROUND_MESSAGE_TAB) {
- // Only verify the title
- assert_tab_titled_from(tabMessageBackground, aMessage);
- }
- if (aFlags & VERIFY_MESSAGE_WINDOW) {
- assert_selected_and_displayed(msgc, aMessage);
- if (aIndex !== undefined) {
- assert_selected_and_displayed(msgc, aIndex);
- }
- }
-}
-
-function test_create_virtual_folders() {
- be_in_folder(baseFolder);
-
- // Apply the mail view
- mc.window.RefreshAllViewPopups(mc.e("viewPickerPopup"));
- mc.window.ViewChange(":$label1");
- wait_for_all_messages_to_load();
-
- // - save it
- plan_for_modal_dialog(
- "mailnews:virtualFolderProperties",
- subtest_save_mail_view
- );
- // we have to use value here because the option mechanism is not sophisticated
- // enough.
- mc.window.ViewChange(MailViewConstants.kViewItemVirtual);
- wait_for_modal_dialog("mailnews:virtualFolderProperties");
-}
-
-function subtest_save_mail_view(savc) {
- savc.window.onOK();
-}
-
-function _open_first_message() {
- // Enter the folder and open a message
- tabFolder = be_in_folder(folder);
- curMessage = select_click_row(0);
- assert_selected_and_displayed(curMessage);
-
- // Open the tab with the message
- tabMessage = open_selected_message_in_new_tab();
- assert_selected_and_displayed(curMessage);
- assert_tab_titled_from(tabMessage, curMessage);
-
- switch_tab(tabFolder);
-
- // Open another tab with the message, this time in the background
- tabMessageBackground = open_selected_message_in_new_tab(true);
- assert_tab_titled_from(tabMessageBackground, curMessage);
-
- // Open the window with the message
- switch_tab(tabFolder);
- msgc = open_selected_message_in_new_window();
- assert_selected_and_displayed(msgc, curMessage);
-}
-
-function test_open_first_message_in_virtual_folder() {
- folder = baseFolder.getChildNamed(baseFolder.prettyName + "-Important");
- if (!folder) {
- throw new Error("DeletionFromVirtualFoldersA-Important was not created!");
- }
-
- _open_first_message();
-}
-
-/**
- * Perform a deletion from the folder tab, verify the others update correctly
- * (advancing to the next message).
- */
-function test_delete_from_virtual_folder_in_folder_tab() {
- // - plan to end up on the guy who is currently at index 1
- curMessage = mc.dbView.getMsgHdrAt(1);
- // while we're at it, figure out who is at 2 for the next step
- nextMessage = mc.dbView.getMsgHdrAt(2);
- // - delete the message
- press_delete();
-
- // - verify all displays
- _verify_message_is_displayed_in(VERIFY_ALL, curMessage, 0);
-}
-
-/**
- * Perform a deletion from the message tab, verify the others update correctly
- * (advancing to the next message).
- */
-function test_delete_from_virtual_folder_in_message_tab() {
- switch_tab(tabMessage);
- // nextMessage is the guy we want to see once the delete completes.
- press_delete();
- curMessage = nextMessage;
-
- // - verify all displays
- _verify_message_is_displayed_in(VERIFY_ALL, curMessage, 0);
-
- // figure out the next guy...
- nextMessage = mc.dbView.getMsgHdrAt(1);
- if (!nextMessage) {
- throw new Error("We ran out of messages early?");
- }
-}
-
-/**
- * Perform a deletion from the message window, verify the others update
- * correctly (advancing to the next message).
- */
-function test_delete_from_virtual_folder_in_message_window() {
- // - delete
- press_delete(msgc);
- curMessage = nextMessage;
- // - verify all displays
- _verify_message_is_displayed_in(VERIFY_ALL, curMessage, 0);
-}
-
-/**
- * Delete the last message in that folder, which should close all message
- * displays.
- */
-function test_delete_last_message_from_virtual_folder_closes_message_displays() {
- // - since we have both foreground and background message tabs, we don't need
- // to open yet another tab to test
-
- // - prep for the message window disappearing
- plan_for_window_close(msgc);
-
- // - let's arbitrarily perform the deletion on this message tab
- switch_tab(tabMessage);
- press_delete();
-
- // - the message window should have gone away...
- // (this also helps ensure that the 3pane gets enough event loop time to do
- // all that it needs to accomplish)
- wait_for_window_close(msgc);
- msgc = null;
-
- // - and we should now be on the folder tab and there should be no other tabs
- if (mc.tabmail.tabInfo.length != 1) {
- throw new Error("There should only be one tab left!");
- }
- // the below check is implied by the previous check if things are sane-ish
- if (mc.tabmail.currentTabInfo != tabFolder) {
- throw new Error("We should be on the folder tab!");
- }
-}
-
-/**
- * Open the first message in the smart inbox.
- */
-function test_open_first_message_in_smart_inbox() {
- // Switch to smart folders
- mc.folderTreeView.mode = "smart";
- // Select the smart inbox
- folder = get_smart_folder_named("Inbox");
- be_in_folder(folder);
- assert_messages_in_view(setNormal);
- // Open the first message
- _open_first_message();
-}
-
-/**
- * Perform a deletion from the folder tab, verify the others update correctly
- * (advancing to the next message).
- */
-function test_delete_from_smart_inbox_in_folder_tab() {
- // - plan to end up on the guy who is currently at index 1
- curMessage = mc.dbView.getMsgHdrAt(1);
- // while we're at it, figure out who is at 2 for the next step
- nextMessage = mc.dbView.getMsgHdrAt(2);
- // - delete the message
- press_delete();
-
- // - verify all displays
- _verify_message_is_displayed_in(VERIFY_ALL, curMessage, 0);
-}
-
-/**
- * Perform a deletion from the message tab, verify the others update correctly
- * (advancing to the next message).
- */
-function test_delete_from_smart_inbox_in_message_tab() {
- switch_tab(tabMessage);
- // nextMessage is the guy we want to see once the delete completes.
- press_delete();
- curMessage = nextMessage;
-
- // - verify all displays
- _verify_message_is_displayed_in(VERIFY_ALL, curMessage, 0);
-
- // figure out the next guy...
- nextMessage = mc.dbView.getMsgHdrAt(1);
- if (!nextMessage) {
- throw new Error("We ran out of messages early?");
- }
-}
-
-/**
- * Perform a deletion from the message window, verify the others update
- * correctly (advancing to the next message).
- */
-function test_delete_from_smart_inbox_in_message_window() {
- // - delete
- press_delete(msgc);
- curMessage = nextMessage;
- // - verify all displays
- _verify_message_is_displayed_in(VERIFY_ALL, curMessage, 0);
-}
-
-/**
- * Delete the last message in that folder, which should close all message
- * displays.
- */
-function test_delete_last_message_from_smart_inbox_closes_message_displays() {
- // - since we have both foreground and background message tabs, we don't need
- // to open yet another tab to test
-
- // - prep for the message window disappearing
- plan_for_window_close(msgc);
-
- // - let's arbitrarily perform the deletion on this message tab
- switch_tab(tabMessage);
- press_delete();
-
- // - the message window should have gone away...
- // (this also helps ensure that the 3pane gets enough event loop time to do
- // all that it needs to accomplish)
- wait_for_window_close(msgc);
- msgc = null;
-
- // - and we should now be on the folder tab and there should be no other tabs
- if (mc.tabmail.tabInfo.length != 1) {
- throw new Error("There should only be one tab left!");
- }
- // the below check is implied by the previous check if things are sane-ish
- if (mc.tabmail.currentTabInfo != tabFolder) {
- throw new Error("We should be on the folder tab!");
- }
-}
-
-/**
- * Switch back to the all folders mode for further tests.
- */
-function test_switch_back_to_all_folders_mode() {
- mc.folderTreeView.mode = "all";
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-display/test-deletion-with-multiple-displays.js
+++ /dev/null
@@ -1,717 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test that deleting a message in a given tab or window properly updates both
- * that tab/window as well as all other tabs/windows. We also test that the
- * message tab title updates appropriately through all of this. We do all of
- * this both for tabs that have ever been opened in the foreground, and tabs
- * that haven't (and thus might have fake selections).
- */
-
-"use strict";
-
-var {
- assert_selected_and_displayed,
- assert_tab_titled_from,
- be_in_folder,
- close_message_window,
- close_tab,
- create_folder,
- make_new_sets_in_folder,
- mc,
- open_selected_message_in_new_tab,
- open_selected_message_in_new_window,
- press_delete,
- select_click_row,
- select_control_click_row,
- select_shift_click_row,
- switch_tab,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { plan_for_window_close, wait_for_window_close } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var folder,
- lastMessageFolder,
- oneBeforeFolder,
- oneAfterFolder,
- multipleDeletionFolder1,
- multipleDeletionFolder2,
- multipleDeletionFolder3,
- multipleDeletionFolder4;
-
-function setupModule(module) {
- folder = create_folder("DeletionA");
- lastMessageFolder = create_folder("DeletionB");
- oneBeforeFolder = create_folder("DeletionC");
- oneAfterFolder = create_folder("DeletionD");
- multipleDeletionFolder1 = create_folder("DeletionE");
- multipleDeletionFolder2 = create_folder("DeletionF");
- multipleDeletionFolder3 = create_folder("DeletionG");
- multipleDeletionFolder4 = create_folder("DeletionH");
- // we want exactly as many messages as we plan to delete, so that we can test
- // that the message window and tabs close when they run out of things to
- // to display.
- make_new_sets_in_folder(folder, [{ count: 4 }]);
-
- // since we don't test window close here, it doesn't really matter how many
- // messages these have
- make_new_sets_in_folder(lastMessageFolder, [{ count: 4 }]);
- make_new_sets_in_folder(oneBeforeFolder, [{ count: 10 }]);
- make_new_sets_in_folder(oneAfterFolder, [{ count: 10 }]);
- make_new_sets_in_folder(multipleDeletionFolder1, [{ count: 30 }]);
-
- // We're depending on selecting the last message here, so these do matter
- make_new_sets_in_folder(multipleDeletionFolder2, [{ count: 10 }]);
- make_new_sets_in_folder(multipleDeletionFolder3, [{ count: 10 }]);
- make_new_sets_in_folder(multipleDeletionFolder4, [{ count: 10 }]);
-}
-
-var tabFolder, tabMessage, tabMessageBackground, curMessage, nextMessage;
-
-/**
- * The message window controller. Short names because controllers get used a
- * lot.
- */
-var msgc;
-
-/**
- * Open up the message at aIndex in all our display mechanisms, and check to see
- * if the displays are all correct. This also sets up all our globals.
- */
-function _open_message_in_all_four_display_mechanisms_helper(aFolder, aIndex) {
- // - Select the message in this tab.
- tabFolder = be_in_folder(aFolder);
- curMessage = select_click_row(aIndex);
- assert_selected_and_displayed(curMessage);
-
- // - Open the tab with the message
- tabMessage = open_selected_message_in_new_tab();
- assert_selected_and_displayed(curMessage);
- assert_tab_titled_from(tabMessage, curMessage);
-
- // go back to the folder tab
- switch_tab(tabFolder);
-
- // - Open another tab with the message, this time in the background
- tabMessageBackground = open_selected_message_in_new_tab(true);
- assert_tab_titled_from(tabMessageBackground, curMessage);
-
- // - Open the window with the message
- // need to go back to the folder tab. (well, should.)
- switch_tab(tabFolder);
- msgc = open_selected_message_in_new_window();
- assert_selected_and_displayed(msgc, curMessage);
-}
-
-// Check whether this message is displayed in the folder tab
-var VERIFY_FOLDER_TAB = 0x1;
-// Check whether this message is displayed in the foreground message tab
-var VERIFY_MESSAGE_TAB = 0x2;
-// Check whether this message is displayed in the background message tab
-var VERIFY_BACKGROUND_MESSAGE_TAB = 0x4;
-// Check whether this message is displayed in the message window
-var VERIFY_MESSAGE_WINDOW = 0x8;
-var VERIFY_ALL = 0xf;
-
-/**
- * Verify that the message is displayed in the given tabs. The index is
- * optional.
- */
-function _verify_message_is_displayed_in(aFlags, aMessage, aIndex) {
- if (aFlags & VERIFY_FOLDER_TAB) {
- switch_tab(tabFolder);
- assert_selected_and_displayed(aMessage);
- if (aIndex !== undefined) {
- assert_selected_and_displayed(aIndex);
- }
- }
- if (aFlags & VERIFY_MESSAGE_TAB) {
- // Verify the title first
- assert_tab_titled_from(tabMessage, aMessage);
- switch_tab(tabMessage);
- // Verify the title again, just in case
- assert_tab_titled_from(tabMessage, aMessage);
- assert_selected_and_displayed(aMessage);
- if (aIndex !== undefined) {
- assert_selected_and_displayed(aIndex);
- }
- }
- if (aFlags & VERIFY_BACKGROUND_MESSAGE_TAB) {
- // Only verify the title
- assert_tab_titled_from(tabMessageBackground, aMessage);
- }
- if (aFlags & VERIFY_MESSAGE_WINDOW) {
- assert_selected_and_displayed(msgc, aMessage);
- if (aIndex !== undefined) {
- assert_selected_and_displayed(msgc, aIndex);
- }
- }
-}
-
-/**
- * Have a message displayed in a folder tab, message tab (foreground and
- * background), and message window. The idea is that as we delete from the
- * various sources, they should all advance in lock-step through their messages,
- * simplifying our lives (but making us explode forevermore the first time any
- * of the tests fail.)
- */
-function test_open_first_message_in_all_four_display_mechanisms() {
- _open_message_in_all_four_display_mechanisms_helper(folder, 0);
-}
-
-/**
- * Perform a deletion from the folder tab, verify the others update correctly
- * (advancing to the next message).
- */
-function test_delete_in_folder_tab() {
- // - plan to end up on the guy who is currently at index 1
- curMessage = mc.dbView.getMsgHdrAt(1);
- // while we're at it, figure out who is at 2 for the next step
- nextMessage = mc.dbView.getMsgHdrAt(2);
- // - delete the message
- press_delete();
-
- // - verify all displays
- _verify_message_is_displayed_in(VERIFY_ALL, curMessage, 0);
-}
-
-/**
- * Perform a deletion from the message tab, verify the others update correctly
- * (advancing to the next message).
- */
-function test_delete_in_message_tab() {
- switch_tab(tabMessage);
- // nextMessage is the guy we want to see once the delete completes.
- press_delete();
- curMessage = nextMessage;
-
- // - verify all displays
- _verify_message_is_displayed_in(VERIFY_ALL, curMessage, 0);
-
- // figure out the next guy...
- nextMessage = mc.dbView.getMsgHdrAt(1);
- if (!nextMessage) {
- throw new Error("We ran out of messages early?");
- }
-}
-
-/**
- * Perform a deletion from the message window, verify the others update
- * correctly (advancing to the next message).
- */
-function test_delete_in_message_window() {
- // - delete
- press_delete(msgc);
- curMessage = nextMessage;
- // - verify all displays
- _verify_message_is_displayed_in(VERIFY_ALL, curMessage, 0);
-}
-
-/**
- * Delete the last message in that folder, which should close all message
- * displays.
- */
-function test_delete_last_message_closes_message_displays() {
- // - since we have both foreground and background message tabs, we don't need
- // to open yet another tab to test
-
- // - prep for the message window disappearing
- plan_for_window_close(msgc);
-
- // - let's arbitrarily perform the deletion on this message tab
- switch_tab(tabMessage);
- press_delete();
-
- // - the message window should have gone away...
- // (this also helps ensure that the 3pane gets enough event loop time to do
- // all that it needs to accomplish)
- wait_for_window_close(msgc);
- msgc = null;
-
- // - and we should now be on the folder tab and there should be no other tabs
- if (mc.tabmail.tabInfo.length != 1) {
- throw new Error("There should only be one tab left!");
- }
- // the below check is implied by the previous check if things are sane-ish
- if (mc.tabmail.currentTabInfo != tabFolder) {
- throw new Error("We should be on the folder tab!");
- }
-}
-
-/*
- * Now we retest everything, but while deleting the last message in our
- * selection. We need to make sure we select the previously next-to-last message
- * in that case.
- */
-
-/**
- * Have the last message displayed in a folder tab, message tab (foreground and
- * background), and message window. The idea is that as we delete from the
- * various sources, they should all advance in lock-step through their messages,
- * simplifying our lives (but making us explode forevermore the first time any
- * of the tests fail.)
- */
-function test_open_last_message_in_all_four_display_mechanisms() {
- // since we have four messages, index 3 is the last message.
- _open_message_in_all_four_display_mechanisms_helper(lastMessageFolder, 3);
-}
-
-/**
- * Perform a deletion from the folder tab, verify the others update correctly
- * (advancing to the next message).
- */
-function test_delete_last_message_in_folder_tab() {
- // - plan to end up on the guy who is currently at index 2
- curMessage = mc.dbView.getMsgHdrAt(2);
- // while we're at it, figure out who is at 1 for the next step
- nextMessage = mc.dbView.getMsgHdrAt(1);
- // - delete the message
- press_delete();
-
- // - verify all displays
- _verify_message_is_displayed_in(VERIFY_ALL, curMessage, 2);
-}
-
-/**
- * Perform a deletion from the message tab, verify the others update correctly
- * (advancing to the next message).
- */
-function test_delete_last_message_in_message_tab() {
- // (we're still on the message tab, and nextMessage is the guy we want to see
- // once the delete completes.)
- press_delete();
- curMessage = nextMessage;
-
- // - verify all displays
- _verify_message_is_displayed_in(VERIFY_ALL, curMessage, 1);
- // figure out the next guy...
-
- nextMessage = mc.dbView.getMsgHdrAt(0);
- if (!nextMessage) {
- throw new Error("We ran out of messages early?");
- }
-}
-
-/**
- * Perform a deletion from the message window, verify the others update
- * correctly (advancing to the next message).
- */
-function test_delete_last_message_in_message_window() {
- // Vary this up. Switch to the folder tab instead of staying on the message
- // tab
- switch_tab(tabFolder);
- // - delete
- press_delete(msgc);
- curMessage = nextMessage;
- // - verify all displays
- _verify_message_is_displayed_in(VERIFY_ALL, curMessage, 0);
-
- // - clean up, close the message window and displays
- close_message_window(msgc);
- close_tab(tabMessage);
- close_tab(tabMessageBackground);
- switch_tab(tabFolder);
-}
-
-/*
- * Our next job is to open up a message, then delete the message one before it
- * in another view. The other selections shouldn't be affected.
- */
-
-/**
- * Test "one before" deletion in the folder tab.
- */
-function test_delete_one_before_message_in_folder_tab() {
- // Open up message 4 in message tabs and a window (we'll delete message 3).
- _open_message_in_all_four_display_mechanisms_helper(oneBeforeFolder, 4);
-
- let expectedMessage = mc.dbView.getMsgHdrAt(4);
- select_click_row(3);
- press_delete();
-
- // The message tab, background message tab and window shouldn't have changed
- _verify_message_is_displayed_in(
- VERIFY_MESSAGE_TAB | VERIFY_BACKGROUND_MESSAGE_TAB | VERIFY_MESSAGE_WINDOW,
- expectedMessage
- );
-
- // Clean up, close everything
- close_message_window(msgc);
- close_tab(tabMessage);
- close_tab(tabMessageBackground);
- switch_tab(tabFolder);
-}
-
-/**
- * Test "one before" deletion in the message tab.
- */
-function test_delete_one_before_message_in_message_tab() {
- // Open up 3 in a message tab, then select and open up 4 in a background tab
- // and window.
- select_click_row(3);
- tabMessage = open_selected_message_in_new_tab(true);
- let expectedMessage = select_click_row(4);
- tabMessageBackground = open_selected_message_in_new_tab(true);
- msgc = open_selected_message_in_new_window(true);
-
- // Switch to the message tab, and delete.
- switch_tab(tabMessage);
- press_delete();
-
- // The folder tab, background message tab and window shouldn't have changed
- _verify_message_is_displayed_in(
- VERIFY_FOLDER_TAB | VERIFY_BACKGROUND_MESSAGE_TAB | VERIFY_MESSAGE_WINDOW,
- expectedMessage
- );
-
- // Clean up, close everything
- close_message_window(msgc);
- close_tab(tabMessage);
- close_tab(tabMessageBackground);
- switch_tab(tabFolder);
-}
-
-/**
- * Test "one before" deletion in the message window.
- */
-function test_delete_one_before_message_in_message_window() {
- // Open up 3 in a message window, then select and open up 4 in a background
- // and a foreground tab.
- select_click_row(3);
- msgc = open_selected_message_in_new_window();
- let expectedMessage = select_click_row(4);
- tabMessage = open_selected_message_in_new_tab();
- switch_tab(tabFolder);
- tabMessageBackground = open_selected_message_in_new_tab(true);
-
- // Press delete in the message window.
- press_delete(msgc);
-
- // The folder tab, message tab and background message tab shouldn't have
- // changed
- _verify_message_is_displayed_in(
- VERIFY_FOLDER_TAB | VERIFY_MESSAGE_TAB | VERIFY_BACKGROUND_MESSAGE_TAB,
- expectedMessage
- );
-
- // Clean up, close everything
- close_message_window(msgc);
- close_tab(tabMessage);
- close_tab(tabMessageBackground);
- switch_tab(tabFolder);
-}
-
-/*
- * Now do all of that again, but this time delete the message _after_ the open one.
- */
-
-/**
- * Test "one after" deletion in the folder tab.
- */
-function test_delete_one_after_message_in_folder_tab() {
- // Open up message 4 in message tabs and a window (we'll delete message 5).
- _open_message_in_all_four_display_mechanisms_helper(oneAfterFolder, 4);
-
- let expectedMessage = mc.dbView.getMsgHdrAt(4);
- select_click_row(5);
- press_delete();
-
- // The message tab, background message tab and window shouldn't have changed
- _verify_message_is_displayed_in(
- VERIFY_MESSAGE_TAB | VERIFY_BACKGROUND_MESSAGE_TAB | VERIFY_MESSAGE_WINDOW,
- expectedMessage
- );
-
- // Clean up, close everything
- close_message_window(msgc);
- close_tab(tabMessage);
- close_tab(tabMessageBackground);
- switch_tab(tabFolder);
-}
-
-/**
- * Test "one after" deletion in the message tab.
- */
-function test_delete_one_after_message_in_message_tab() {
- // Open up 5 in a message tab, then select and open up 4 in a background tab
- // and window.
- select_click_row(5);
- tabMessage = open_selected_message_in_new_tab(true);
- let expectedMessage = select_click_row(4);
- tabMessageBackground = open_selected_message_in_new_tab(true);
- msgc = open_selected_message_in_new_window(true);
-
- // Switch to the message tab, and delete.
- switch_tab(tabMessage);
- press_delete();
-
- // The folder tab, background message tab and window shouldn't have changed
- _verify_message_is_displayed_in(
- VERIFY_FOLDER_TAB | VERIFY_BACKGROUND_MESSAGE_TAB | VERIFY_MESSAGE_WINDOW,
- expectedMessage
- );
-
- // Clean up, close everything
- close_message_window(msgc);
- close_tab(tabMessage);
- close_tab(tabMessageBackground);
- switch_tab(tabFolder);
-}
-
-/**
- * Test "one after" deletion in the message window.
- */
-function test_delete_one_after_message_in_message_window() {
- // Open up 5 in a message window, then select and open up 4 in a background
- // and a foreground tab.
- select_click_row(5);
- msgc = open_selected_message_in_new_window();
- let expectedMessage = select_click_row(4);
- tabMessage = open_selected_message_in_new_tab();
- switch_tab(tabFolder);
- tabMessageBackground = open_selected_message_in_new_tab(true);
-
- // Press delete in the message window.
- press_delete(msgc);
-
- // The folder tab, message tab and background message tab shouldn't have
- // changed
- _verify_message_is_displayed_in(
- VERIFY_FOLDER_TAB | VERIFY_MESSAGE_TAB | VERIFY_BACKGROUND_MESSAGE_TAB,
- expectedMessage
- );
-
- // Clean up, close everything
- close_message_window(msgc);
- close_tab(tabMessage);
- close_tab(tabMessageBackground);
- switch_tab(tabFolder);
-}
-
-/*
- * Delete multiple messages in a folder tab. Make sure message displays at the
- * beginning, middle and end of a selection work out.
- */
-
-/**
- * Test deleting multiple messages in a folder tab, with message displays open
- * to the beginning of a selection.
- */
-function test_delete_multiple_messages_with_first_selected_message_open() {
- // Open up 2 in a message tab, background tab, and message window.
- _open_message_in_all_four_display_mechanisms_helper(
- multipleDeletionFolder1,
- 2
- );
-
- // We'll select 2-5, 8, 9 and 10. We expect 6 to be the next displayed
- // message.
- select_click_row(2);
- select_shift_click_row(5);
- select_control_click_row(8);
- select_control_click_row(9);
- select_control_click_row(10);
- let expectedMessage = mc.dbView.getMsgHdrAt(6);
-
- // Delete the selected messages
- press_delete();
-
- // All the displays should now be showing the expectedMessage
- _verify_message_is_displayed_in(VERIFY_ALL, expectedMessage);
-
- // Clean up, close everything
- close_message_window(msgc);
- close_tab(tabMessage);
- close_tab(tabMessageBackground);
- switch_tab(tabFolder);
-}
-
-/**
- * Test deleting multiple messages in a folder tab, with message displays open
- * to somewhere in the middle of a selection.
- */
-function test_delete_multiple_messages_with_nth_selected_message_open() {
- // Open up 9 in a message tab, background tab, and message window.
- _open_message_in_all_four_display_mechanisms_helper(
- multipleDeletionFolder1,
- 9
- );
-
- // We'll select 2-5, 8, 9 and 10. We expect 11 to be the next displayed
- // message.
- select_click_row(2);
- select_shift_click_row(5);
- select_control_click_row(8);
- select_control_click_row(9);
- select_control_click_row(10);
- let expectedMessage = mc.dbView.getMsgHdrAt(11);
-
- // Delete the selected messages
- press_delete();
-
- // The folder tab should now be showing message 2
- assert_selected_and_displayed(2);
-
- // The other displays should now be showing the expectedMessage
- _verify_message_is_displayed_in(
- VERIFY_MESSAGE_TAB | VERIFY_BACKGROUND_MESSAGE_TAB | VERIFY_MESSAGE_WINDOW,
- expectedMessage
- );
-
- // Clean up, close everything
- close_message_window(msgc);
- close_tab(tabMessage);
- close_tab(tabMessageBackground);
- switch_tab(tabFolder);
-}
-
-/**
- * Test deleting multiple messages in a folder tab, with message displays open
- * to the end of a selection.
- */
-function test_delete_multiple_messages_with_last_selected_message_open() {
- // Open up 10 in a message tab, background tab, and message window.
- _open_message_in_all_four_display_mechanisms_helper(
- multipleDeletionFolder1,
- 9
- );
-
- // We'll select 2-5, 8, 9 and 10. We expect 11 to be the next displayed
- // message.
- select_click_row(2);
- select_shift_click_row(5);
- select_control_click_row(8);
- select_control_click_row(9);
- select_control_click_row(10);
- let expectedMessage = mc.dbView.getMsgHdrAt(11);
-
- // Delete the selected messages
- press_delete();
-
- // The folder tab should now be showing message 2
- assert_selected_and_displayed(2);
-
- // The other displays should now be showing the expectedMessage
- _verify_message_is_displayed_in(
- VERIFY_MESSAGE_TAB | VERIFY_BACKGROUND_MESSAGE_TAB | VERIFY_MESSAGE_WINDOW,
- expectedMessage
- );
- // Clean up, close everything
- close_message_window(msgc);
- close_tab(tabMessage);
- close_tab(tabMessageBackground);
- switch_tab(tabFolder);
-}
-
-/**
- * Test deleting multiple messages in a folder tab (including the last one!),
- * with message displays open to the beginning of a selection.
- */
-function test_delete_multiple_messages_including_the_last_one_with_first_open() {
- // 10 messages in this folder. Open up message 1 everywhere.
- _open_message_in_all_four_display_mechanisms_helper(
- multipleDeletionFolder2,
- 1
- );
-
- // We'll select 1-4, 7, 8 and 9. We expect 5 to be the next displayed message.
- select_click_row(1);
- select_shift_click_row(4);
- select_control_click_row(7);
- select_control_click_row(8);
- select_control_click_row(9);
- let expectedMessage = mc.dbView.getMsgHdrAt(5);
-
- // Delete the selected messages
- press_delete();
-
- // All the displays should now be showing the expectedMessage
- _verify_message_is_displayed_in(VERIFY_ALL, expectedMessage);
-
- // Clean up, close everything
- close_message_window(msgc);
- close_tab(tabMessage);
- close_tab(tabMessageBackground);
- switch_tab(tabFolder);
-}
-
-/**
- * Test deleting multiple messages in a folder tab (including the last one!),
- * with message displays open to the middle of a selection.
- */
-function test_delete_multiple_messages_including_the_last_one_with_nth_open() {
- // 10 messages in this folder. Open up message 7 everywhere.
- _open_message_in_all_four_display_mechanisms_helper(
- multipleDeletionFolder3,
- 7
- );
-
- // We'll select 1-4, 7, 8 and 9. We expect 6 to be the next displayed message.
- select_click_row(1);
- select_shift_click_row(4);
- select_control_click_row(7);
- select_control_click_row(8);
- select_control_click_row(9);
- let expectedMessage = mc.dbView.getMsgHdrAt(6);
-
- // Delete the selected messages
- press_delete();
-
- // The folder tab should now be showing message 1
- assert_selected_and_displayed(1);
-
- // The other displays should now be showing the expectedMessage
- _verify_message_is_displayed_in(
- VERIFY_MESSAGE_TAB | VERIFY_BACKGROUND_MESSAGE_TAB | VERIFY_MESSAGE_WINDOW,
- expectedMessage
- );
-
- // Clean up, close everything
- close_message_window(msgc);
- close_tab(tabMessage);
- close_tab(tabMessageBackground);
- switch_tab(tabFolder);
-}
-
-/**
- * Test deleting multiple messages in a folder tab (including the last one!),
- * with message displays open to the end of a selection.
- */
-function test_delete_multiple_messages_including_the_last_one_with_last_open() {
- // 10 messages in this folder. Open up message 9 everywhere.
- _open_message_in_all_four_display_mechanisms_helper(
- multipleDeletionFolder4,
- 9
- );
-
- // We'll select 1-4, 7, 8 and 9. We expect 6 to be the next displayed message.
- select_click_row(1);
- select_shift_click_row(4);
- select_control_click_row(7);
- select_control_click_row(8);
- select_control_click_row(9);
- let expectedMessage = mc.dbView.getMsgHdrAt(6);
-
- // Delete the selected messages
- press_delete();
-
- // The folder tab should now be showing message 1
- assert_selected_and_displayed(1);
-
- // The other displays should now be showing the expectedMessage
- _verify_message_is_displayed_in(
- VERIFY_MESSAGE_TAB | VERIFY_BACKGROUND_MESSAGE_TAB | VERIFY_MESSAGE_WINDOW,
- expectedMessage
- );
-
- // Clean up, close everything
- close_message_window(msgc);
- close_tab(tabMessage);
- close_tab(tabMessageBackground);
- switch_tab(tabFolder);
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-display/test-display-name.js
+++ /dev/null
@@ -1,243 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test that the display names in email addresses are correctly shown in the
- * thread pane.
- */
-
-"use strict";
-
-var { ensure_card_exists } = ChromeUtils.import(
- "resource://testing-common/mozmill/AddressBookHelpers.jsm"
-);
-var {
- add_message_to_folder,
- assert_equals,
- be_in_folder,
- create_folder,
- create_message,
- mc,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var folder;
-
-var messages = [
- // Basic From header tests
- {
- name: "from_display_name_unquoted",
- headers: { From: "Carter Burke <cburke@wyutani.invalid>" },
- expected: { column: "from", value: "Carter Burke" },
- },
- {
- name: "from_display_name_quoted",
- headers: { From: '"Ellen Ripley" <eripley@wyutani.invalid>' },
- expected: { column: "from", value: "Ellen Ripley" },
- },
- {
- name: "from_display_name_with_comma",
- headers: { From: '"William Gorman, Lt." <wgorman@uscmc.invalid>' },
- expected: { column: "from", value: "William Gorman, Lt." },
- },
- {
- name: "from_email_raw",
- headers: { From: "dhicks@uscmc.invalid" },
- expected: { column: "from", value: "dhicks@uscmc.invalid" },
- },
- {
- name: "from_email_in_angle_brackets",
- headers: { From: "<whudson@uscmc.invalid>" },
- expected: { column: "from", value: "whudson@uscmc.invalid" },
- },
-
- // Basic To header tests
- {
- name: "to_display_name_unquoted",
- headers: { To: "Carter Burke <cburke@wyutani.invalid>" },
- expected: { column: "recipients", value: "Carter Burke" },
- },
- {
- name: "to_display_name_quoted",
- headers: { To: '"Ellen Ripley" <eripley@wyutani.invalid>' },
- expected: { column: "recipients", value: "Ellen Ripley" },
- },
- {
- name: "to_display_name_with_comma",
- headers: { To: '"William Gorman, Lt." <wgorman@uscmc.invalid>' },
- expected: { column: "recipients", value: "William Gorman, Lt." },
- },
- {
- name: "to_email_raw",
- headers: { To: "dhicks@uscmc.invalid" },
- expected: { column: "recipients", value: "dhicks@uscmc.invalid" },
- },
- {
- name: "to_email_in_angle_brackets",
- headers: { To: "<whudson@uscmc.invalid>" },
- expected: { column: "recipients", value: "whudson@uscmc.invalid" },
- },
- {
- name: "to_display_name_multiple",
- headers: {
- To:
- "Carter Burke <cburke@wyutani.invalid>, " +
- "Dwayne Hicks <dhicks@uscmc.invalid>",
- },
- expected: { column: "recipients", value: "Carter Burke, Dwayne Hicks" },
- },
-
- // Address book tests
- {
- name: "from_in_abook_pdn",
- headers: { From: "Al Apone <aapone@uscmc.invalid>" },
- expected: { column: "from", value: "Sarge" },
- },
- {
- name: "from_in_abook_no_pdn",
- headers: { From: "Rebeccah Jorden <rjorden@hadleys-hope.invalid>" },
- expected: { column: "from", value: "Rebeccah Jorden" },
- },
- {
- name: "to_in_abook_pdn",
- headers: { To: "Al Apone <aapone@uscmc.invalid>" },
- expected: { column: "recipients", value: "Sarge" },
- },
- {
- name: "to_in_abook_no_pdn",
- headers: { To: "Rebeccah Jorden <rjorden@hadleys-hope.invalid>" },
- expected: { column: "recipients", value: "Rebeccah Jorden" },
- },
- {
- name: "to_in_abook_multiple_mixed_pdn",
- headers: {
- To:
- "Al Apone <aapone@uscmc.invalid>, " +
- "Rebeccah Jorden <rjorden@hadleys-hope.invalid>",
- },
- expected: { column: "recipients", value: "Sarge, Rebeccah Jorden" },
- },
-
- // Esoteric tests; these mainly test that we're getting the expected info back
- // from the message header.
- {
- name: "from_display_name_multiple",
- headers: {
- From:
- "Carter Burke <cburke@wyutani.invalid>, " +
- "Dwayne Hicks <dhicks@uscmc.invalid>",
- },
- expected: { column: "from", value: "Carter Burke et al." },
- },
- {
- name: "from_missing",
- headers: { From: null },
- expected: { column: "from", value: "" },
- },
- {
- name: "from_empty",
- headers: { From: "" },
- expected: { column: "from", value: "" },
- },
- {
- name: "from_invalid",
- headers: { From: "invalid" },
- expected: { column: "from", value: "invalid" },
- },
- {
- name: "from_and_sender_display_name",
- headers: {
- From: "Carter Burke <cburke@wyutani.invalid>",
- Sender: "The Company <thecompany@wyutani.invalid>",
- },
- expected: { column: "from", value: "Carter Burke" },
- },
- {
- name: "sender_and_no_from_display_name",
- headers: { From: null, Sender: "The Company <thecompany@wyutani.invalid>" },
- expected: { column: "from", value: "The Company" },
- },
- {
- name: "to_missing",
- headers: { To: null },
- expected: { column: "recipients", value: "" },
- },
- {
- name: "to_empty",
- headers: { To: "" },
- expected: { column: "recipients", value: "" },
- },
- {
- name: "to_invalid",
- headers: { To: "invalid" },
- expected: { column: "recipients", value: "invalid" },
- },
- {
- name: "to_and_cc_display_name",
- headers: {
- To: "Carter Burke <cburke@wyutani.invalid>",
- Cc: "The Company <thecompany@wyutani.invalid>",
- },
- expected: { column: "recipients", value: "Carter Burke" },
- },
- {
- name: "cc_and_no_to_display_name",
- headers: { To: null, Cc: "The Company <thecompany@wyutani.invalid>" },
- expected: { column: "recipients", value: "The Company" },
- },
-];
-
-var contacts = [
- { email: "aapone@uscmc.invalid", name: "Sarge", pdn: true },
- { email: "rjorden@hadleys-hope.invalid", name: "Newt", pdn: false },
-];
-
-function setupModule(module) {
- folder = create_folder("DisplayNameA");
-
- for (let message of messages) {
- add_message_to_folder(
- folder,
- create_message({
- clobberHeaders: message.headers,
- })
- );
- }
-
- for (let contact of contacts) {
- ensure_card_exists(contact.email, contact.name, contact.pdn);
- }
-}
-
-function check_display_name(index, columnName, expectedName) {
- let columnId;
- switch (columnName) {
- case "from":
- columnId = "senderCol";
- break;
- case "recipients":
- columnId = "recipientCol";
- break;
- default:
- throw new Error("unknown column name: " + columnName);
- }
-
- // Select the nth message
- be_in_folder(folder);
- select_click_row(index);
-
- let tree = mc.folderDisplay.tree;
- let cellText = tree.view.getCellText(index, tree.columns[columnId]);
-
- assert_equals(cellText, expectedName, columnName);
-}
-
-// Generate a test for each message in |messages|.
-for (let [i, message] of messages.entries()) {
- this["test_" + message.name] = function(i, message) {
- check_display_name(i, message.expected.column, message.expected.value);
- }.bind(this, i, message);
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-display/test-folder-pane-visibility.js
+++ /dev/null
@@ -1,271 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test that the folder pane collapses properly, stays collapsed amongst tab
- * changes, and that persistence works (to a first approximation).
- */
-
-"use strict";
-
-var {
- be_in_folder,
- close_tab,
- create_folder,
- make_new_sets_in_folder,
- mc,
- open_folder_in_new_tab,
- open_selected_message_in_new_tab,
- select_click_row,
- switch_tab,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var folder;
-
-function setupModule(module) {
- folder = create_folder("FolderPaneVisibility");
- make_new_sets_in_folder(folder, [{ count: 3 }]);
-}
-
-/**
- * When displaying a folder, assert that the folder pane is visible and all the
- * menus, splitters, etc. are set up right.
- */
-function assert_folder_pane_visible() {
- if (!mc.folderDisplay.folderPaneVisible) {
- throw new Error(
- "The folder display does not think that the folder pane " +
- "is visible, but it should!"
- );
- }
-
- // - folder pane should be visible
- if (mc.e("folderPaneBox").collapsed === true) {
- throw new Error("folderPaneBox should not be collapsed!");
- }
-
- // - the folder pane splitter should not be collapsed
- if (mc.e("folderpane_splitter").collapsed === true) {
- throw new Error("folderpane_splitter should not be collapsed!");
- }
-
- // - the menu item should be checked
- // force the view menu to update.
- mc.window.view_init();
- let paneMenuItem = mc.e("menu_showFolderPane");
- if (paneMenuItem.getAttribute("checked") != "true") {
- throw new Error("The Folder Pane menu item should be checked.");
- }
-}
-
-/**
- * When displaying a folder, assert that the folder pane is hidden and all the
- * menus, splitters, etc. are set up right.
- *
- * @param aFolderPaneIllegal Is the folder pane illegal to display at this time?
- * This impacts whether the folder pane splitter should be visible.
- */
-function assert_folder_pane_hidden(aFolderPaneIllegal) {
- if (mc.folderDisplay.folderPaneVisible) {
- throw new Error(
- "The folder display thinks that the folder pane is " +
- "visible, but it shouldn't!"
- );
- }
-
- // - folder pane shouldn't be visible
- if (mc.e("folderPaneBox").collapsed === false) {
- throw new Error("folderPaneBox should be collapsed!");
- }
-
- // force the view menu to update.
- mc.window.view_init();
- let paneMenuItem = mc.e("menu_showFolderPane");
- // - the folder pane splitter should or should not be collapsed, depending on
- // aFolderPaneIllegal
- if (aFolderPaneIllegal) {
- if (mc.e("folderpane_splitter").collapsed === false) {
- throw new Error("folderpane_splitter should be collapsed!");
- }
- // if (paneMenuItem.getAttribute("disabled") != "true")
- // throw new Error("The Folder Pane menu item should be disabled.");
- } else {
- if (mc.e("folderpane_splitter").collapsed === true) {
- throw new Error("folderpane_splitter should not be collapsed!");
- }
- if (paneMenuItem.getAttribute("checked") == "true") {
- throw new Error("The Folder Pane menu item should not be checked.");
- }
- }
-}
-
-function toggle_folder_pane() {
- // Since we don't have a shortcut to toggle the folder pane, we're going to
- // have to collapse it ourselves
- mc.window.MsgToggleFolderPane();
-}
-
-/**
- * By default, the folder pane should be visible.
- */
-function test_folder_pane_visible_state_is_right() {
- be_in_folder(folder);
- assert_folder_pane_visible();
-}
-
-/**
- * Toggle the folder pane off.
- */
-function test_toggle_folder_pane_off() {
- toggle_folder_pane();
- assert_folder_pane_hidden();
-}
-
-/**
- * Toggle the folder pane on.
- */
-function test_toggle_folder_pane_on() {
- toggle_folder_pane();
- assert_folder_pane_visible();
-}
-
-/**
- * Make sure that switching to message tabs of folder tabs with a different
- * folder pane state does not break. This test should cover all transition
- * states.
- */
-function test_folder_pane_is_sticky() {
- let tabFolderA = be_in_folder(folder);
- assert_folder_pane_visible();
-
- // [folder+ => (new) message]
- select_click_row(0);
- let tabMessage = open_selected_message_in_new_tab();
- assert_folder_pane_hidden(true);
-
- // [message => folder+]
- switch_tab(tabFolderA);
- assert_folder_pane_visible();
-
- // [folder+ => (new) folder+]
- let tabFolderB = open_folder_in_new_tab(folder);
- assert_folder_pane_visible();
-
- // [folder pane toggle + => -]
- toggle_folder_pane();
- assert_folder_pane_hidden();
-
- // [folder- => folder+]
- switch_tab(tabFolderA);
- assert_folder_pane_visible();
-
- // (redundant) [ folder pane toggle + => -]
- toggle_folder_pane();
- assert_folder_pane_hidden();
-
- // [folder- => message]
- switch_tab(tabMessage);
- assert_folder_pane_hidden(true);
-
- // [message => folder-]
- close_tab(tabMessage);
- assert_folder_pane_hidden();
-
- // [folder- => (new) folder-]
- // (we are testing inheritance here)
- let tabFolderC = open_folder_in_new_tab(folder);
- assert_folder_pane_hidden();
-
- // [folder- => folder-]
- close_tab(tabFolderC);
- // the tab we are on now doesn't matter, so we don't care
- assert_folder_pane_hidden();
- switch_tab(tabFolderB);
-
- // [ folder pane toggle - => + ]
- toggle_folder_pane();
- assert_folder_pane_visible();
-
- // [folder+ => folder-]
- close_tab(tabFolderB);
- assert_folder_pane_hidden();
-
- // (redundant) [ folder pane toggle - => + ]
- toggle_folder_pane();
- assert_folder_pane_visible();
-}
-
-/**
- * Test that if we serialize and restore the tabs then the folder pane is in the
- * expected collapsed/non-collapsed state. Because of the special "first tab"
- * situation, we need to do this twice to test each case for the first tab. For
- * additional thoroughness we also flip the state we have the other tabs be in.
- */
-function test_folder_pane_persistence_generally_works() {
- be_in_folder(folder);
-
- // helper to open tabs with the folder pane in the desired states (1 for
- // visible, 0 for hidden)
- function openTabs(aConfig) {
- let curState;
- for (let [iTab, folderPaneVisible] of aConfig.entries()) {
- if (iTab == 0) {
- curState = folderPaneVisible;
- } else {
- open_folder_in_new_tab(folder);
- if (curState != folderPaneVisible) {
- toggle_folder_pane();
- curState = folderPaneVisible;
- }
- }
- }
- }
-
- // close everything but the first tab.
- function closeTabs() {
- while (mc.tabmail.tabInfo.length > 1) {
- mc.tabmail.closeTab(1);
- }
- }
-
- function verifyTabs(aConfig) {
- for (let [iTab, folderPaneVisible] of aConfig.entries()) {
- switch_tab(iTab);
- dump(" checking tab: " + iTab + "\n");
- if (folderPaneVisible) {
- assert_folder_pane_visible();
- } else {
- assert_folder_pane_hidden();
- }
- }
- }
-
- let configs = [
- // 1st time: [+ - - + +]
- [1, 0, 0, 1, 1],
- // 2nd time: [- + + - -]
- [0, 1, 1, 0, 0],
- ];
-
- for (let config of configs) {
- openTabs(config);
- verifyTabs(config); // make sure openTabs did its job right
- let state = mc.tabmail.persistTabs();
- closeTabs();
- // toggle the state for the current tab so we can be sure that it knows how
- // to change things.
- toggle_folder_pane();
- mc.tabmail.restoreTabs(state);
- verifyTabs(config);
- closeTabs();
-
- // toggle the first tab again. This sets - properly for the second pass and
- // restores it to + for when we are done.
- toggle_folder_pane();
- }
- // For one last time, make sure.
- assert_folder_pane_visible();
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-display/test-folder-toolbar.js
+++ /dev/null
@@ -1,140 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test that opening new folder and message tabs has the expected result and
- * that closing them doesn't break anything.
- */
-
-"use strict";
-
-var {
- add_to_toolbar,
- assert_equals,
- assert_folder_selected_and_displayed,
- assert_nothing_selected,
- be_in_folder,
- close_tab,
- create_folder,
- make_new_sets_in_folder,
- mc,
- open_folder_in_new_tab,
- open_selected_message_in_new_tab,
- remove_from_toolbar,
- select_click_row,
- switch_tab,
- wait_for_blank_content_pane,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var folderA, folderB;
-
-function setupModule(module) {
- folderA = create_folder("FolderToolbarA");
- // we need one message to select and open
- folderB = create_folder("FolderToolbarB");
- make_new_sets_in_folder(folderB, [{ count: 1 }]);
-}
-
-function test_add_folder_toolbar() {
- // It should not be present by default
- let folderLoc = mc.eid("locationFolders");
- mc.assertNodeNotExist(folderLoc);
-
- // But it should show up when we call
- add_to_toolbar(mc.e("mail-bar3"), "folder-location-container");
- folderLoc = mc.eid("locationFolders");
- mc.assertNode(folderLoc);
-
- assert_equals(
- !!folderLoc.node.label,
- true,
- "Uninitialized Folder doesn't have a default label."
- );
-}
-
-function test_folder_toolbar_shows_correct_item() {
- add_to_toolbar(mc.e("mail-bar3"), "folder-location-container");
- let folderLoc = mc.eid("locationFolders");
-
- // Start in folder a.
- let tabFolderA = be_in_folder(folderA);
- assert_folder_selected_and_displayed(folderA);
- assert_nothing_selected();
- assert_equals(
- folderLoc.node.label,
- "FolderToolbarA",
- "Opening FolderA doesn't update toolbar."
- );
-
- // Open tab b, make sure it works right.
- let tabFolderB = open_folder_in_new_tab(folderB);
- wait_for_blank_content_pane();
- assert_folder_selected_and_displayed(folderB);
- assert_nothing_selected();
- assert_equals(
- folderLoc.node.label,
- "FolderToolbarB",
- "Opening FolderB in a tab doesn't update toolbar."
- );
-
- // Go back to tab/folder A and make sure we change correctly.
- switch_tab(tabFolderA);
- assert_folder_selected_and_displayed(folderA);
- assert_nothing_selected();
- assert_equals(
- folderLoc.node.label,
- "FolderToolbarA",
- "Switching back to FolderA's tab doesn't update toolbar."
- );
-
- // Go back to tab/folder A and make sure we change correctly.
- switch_tab(tabFolderB);
- assert_folder_selected_and_displayed(folderB);
- assert_nothing_selected();
- assert_equals(
- folderLoc.node.label,
- "FolderToolbarB",
- "Switching back to FolderB's tab doesn't update toolbar."
- );
- close_tab(tabFolderB);
-}
-
-function test_folder_toolbar_disappears_on_message_tab() {
- add_to_toolbar(mc.e("mail-bar3"), "folder-location-container");
- be_in_folder(folderB);
- let folderLoc = mc.eid("locationFolders");
- mc.assertNode(folderLoc);
- assert_equals(
- folderLoc.node.label,
- "FolderToolbarB",
- "We should have started in FolderB."
- );
- assert_equals(
- folderLoc.node.collapsed,
- false,
- "The toolbar should be shown."
- );
-
- // Select one message
- select_click_row(0);
- // Open it
- let messageTab = open_selected_message_in_new_tab();
-
- assert_equals(
- mc.e("folder-location-container").collapsed,
- true,
- "The toolbar should be hidden."
- );
-
- // Clean up, close the tab
- close_tab(messageTab);
-}
-
-function test_remove_folder_toolbar() {
- remove_from_toolbar(mc.e("mail-bar3"), "folder-location-container");
-
- mc.assertNodeNotExist(mc.eid("locationFolders"));
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-display/test-invalid-db-folder-load.js
+++ /dev/null
@@ -1,52 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test that clicking on a folder with an invalid or missing .msf file
- * regenerates the.msf file and loads the view.
- * Also, check that rebuilding the index on a loaded folder reloads the folder.
- */
-
-"use strict";
-
-var {
- assert_messages_in_view,
- assert_selected_and_displayed,
- be_in_folder,
- create_folder,
- make_new_sets_in_folder,
- mc,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var folder;
-var setA;
-
-function setupModule(module) {
- folder = create_folder("InvalidMSF");
- [setA] = make_new_sets_in_folder(folder, [{ count: 3 }]);
-}
-
-/**
- * Check if the db of a folder assumed to be invalid can be restored.
- */
-function test_load_folder_with_invalidDB() {
- folder.msgDatabase.dBFolderInfo.sortType = Ci.nsMsgViewSortType.bySubject;
- folder.msgDatabase.summaryValid = false;
- folder.msgDatabase.ForceClosed();
- folder.msgDatabase = null;
- be_in_folder(folder);
-
- assert_messages_in_view(setA);
- var curMessage = select_click_row(0);
- assert_selected_and_displayed(curMessage);
-}
-
-function test_view_sort_maintained() {
- if (mc.dbView.sortType != Ci.nsMsgViewSortType.bySubject) {
- throw new Error("view sort type not restored from invalid db");
- }
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-display/test-mail-views.js
+++ /dev/null
@@ -1,102 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-
-var {
- assert_messages_in_view,
- be_in_folder,
- create_folder,
- make_new_sets_in_folder,
- mc,
- wait_for_all_messages_to_load,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { plan_for_modal_dialog, wait_for_modal_dialog } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { MailViewConstants } = ChromeUtils.import(
- "resource:///modules/MailViewManager.jsm"
-);
-
-var baseFolder, savedFolder;
-var setUntagged, setTagged;
-
-var setupModule = function(module) {
- // Create a folder with some messages that have no tags and some that are
- // tagged Important ($label1).
- baseFolder = create_folder("MailViewA");
- [setUntagged, setTagged] = make_new_sets_in_folder(baseFolder, [{}, {}]);
- setTagged.addTag("$label1"); // Important, by default
-};
-
-function test_put_view_picker_on_toolbar() {
- let toolbar = mc.e("mail-bar3");
- toolbar.insertItem("mailviews-container", null);
- mc.assertNode(mc.eid("mailviews-container"));
-}
-
-/**
- * https://bugzilla.mozilla.org/show_bug.cgi?id=474701#c97
- */
-function test_save_view_as_folder() {
- // - enter the folder
- be_in_folder(baseFolder);
-
- // - apply the mail view
- // okay, mozmill is just not ready to click on the view picker...
- // just call the ViewChange global. it's sad, but it has the same effects.
- // at least, it does once we've caused the popups to get refreshed.
- mc.window.RefreshAllViewPopups(mc.e("viewPickerPopup"));
- mc.window.ViewChange(":$label1");
- wait_for_all_messages_to_load();
-
- // - save it
- plan_for_modal_dialog(
- "mailnews:virtualFolderProperties",
- subtest_save_mail_view
- );
- // we have to use value here because the option mechanism is not sophisticated
- // enough.
- mc.window.ViewChange(MailViewConstants.kViewItemVirtual);
- wait_for_modal_dialog("mailnews:virtualFolderProperties");
-}
-
-function subtest_save_mail_view(savc) {
- // - make sure the name is right
- savc.assertValue(savc.eid("name"), baseFolder.prettyName + "-Important");
-
- let elem = savc.window.document.getElementById("searchVal0");
- let index = 0;
-
- if (elem.hasAttribute("selectedIndex")) {
- index = parseInt(elem.getAttribute("selectedIndex"));
- }
-
- elem = elem.children[index];
-
- // - make sure the constraint is right
- savc.assertValue(new elib.Elem(elem), "$label1");
-
- // - save it
- savc.window.onOK();
-}
-
-function test_verify_saved_mail_view() {
- // - make sure the folder got created
- savedFolder = baseFolder.getChildNamed(baseFolder.prettyName + "-Important");
- if (!savedFolder) {
- throw new Error("MailViewA-Important was not created!");
- }
-
- // - go in the folder and make sure the right messages are displayed
- be_in_folder(savedFolder);
- assert_messages_in_view(setTagged, mc);
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-display/test-message-commands-on-msgstore.js
+++ /dev/null
@@ -1,300 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * This tests some commands on messages via the UI. But we specifically check,
- * whether the commands have an effect in the message store on disk, i.e. the
- * markings on the messages are stored in the msgStore, not only in the database.
- * For now, it checks for bug 840418.
- */
-
-"use strict";
-
-var {
- open_compose_with_forward,
- open_compose_with_reply,
- setup_msg_contents,
-} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
-var {
- assert_equals,
- assert_false,
- assert_not_equals,
- assert_true,
- be_in_folder,
- create_folder,
- empty_folder,
- get_special_folder,
- make_new_sets_in_folder,
- mc,
- press_delete,
- right_click_on_row,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { plan_for_window_close, wait_for_window_close } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-var { IOUtils } = ChromeUtils.import("resource:///modules/IOUtils.js");
-
-var statusHeader = "X-Mozilla-Status: ";
-
-var gInbox;
-var gOutbox;
-var gAutoRead;
-
-function setupModule(module) {
- gAutoRead = Services.prefs.getBoolPref("mailnews.mark_message_read.auto");
- Services.prefs.setBoolPref("mailnews.mark_message_read.auto", false);
-
- gOutbox = get_special_folder(Ci.nsMsgFolderFlags.Queue);
- gInbox = create_folder("MsgStoreChecks");
- make_new_sets_in_folder(gInbox, [{ count: 6 }]);
-
- // We delete the first message so that we have to compact anything.
- be_in_folder(gInbox);
- let curMessage = select_click_row(0);
- press_delete(mc);
- assert_not_equals(curMessage, select_click_row(0));
-
- let urlListener = {
- compactDone: false,
-
- OnStartRunningUrl(aUrl) {},
- OnStopRunningUrl(aUrl, aExitCode) {
- assert_equals(aExitCode, 0);
- assert_true(gInbox.msgDatabase.summaryValid);
- this.compactDone = true;
- },
- };
-
- // Compaction adds the X-Mozilla-Status rows into the messages
- // that we will need later on.
- assert_true(gInbox.msgStore.supportsCompaction);
- gInbox.compact(urlListener, null);
-
- mc.waitFor(
- function() {
- return urlListener.compactDone;
- },
- "Timeout waiting for compact to complete",
- 10000,
- 100
- );
-}
-
-/**
- * Checks that a message has particular status stored in the data file.
- * Either the aMsgHdr or the aOffset+aStatusOffset must be non-null.
- *
- * @param aMsgHdr The nsIMsgDBHdr header of the message to check. Optional.
- * @param aOffset Offset in the file where the message data starts. Optional.
- * @param aStatusOffset Offset from the start of the message where the status line is. Optional.
- * @param aStatus The required status of the message.
- */
-function check_status(aMsgHdr, aOffset, aStatusOffset, aStatus) {
- if (aOffset == null) {
- aOffset = aMsgHdr.messageOffset;
- }
- if (aStatusOffset == null) {
- aStatusOffset = aMsgHdr.statusOffset;
- }
-
- let folder = aMsgHdr == null ? gInbox : aMsgHdr.folder;
-
- let mboxstring = IOUtils.loadFileToString(folder.filePath);
-
- let expectedStatusString = aStatus.toString(16);
- while (expectedStatusString.length < 4) {
- expectedStatusString = "0" + expectedStatusString;
- }
-
- assert_equals(
- mboxstring.substr(aOffset + aStatusOffset, statusHeader.length),
- statusHeader,
- "The header '" +
- statusHeader +
- "' not found at offset: " +
- aOffset +
- ", statusOffset: " +
- aStatusOffset
- );
- assert_equals(
- mboxstring.substr(aOffset + aStatusOffset + statusHeader.length, 4),
- expectedStatusString
- );
-}
-
-function test_mark_messages_read() {
- // 5 messages in the folder
- be_in_folder(gInbox);
- let curMessage = select_click_row(0);
- // Store the values because they will be unavailable via the hdr
- // after the message is deleted.
- let offset = curMessage.messageOffset;
- let statusOffset = curMessage.statusOffset;
- check_status(curMessage, null, null, 0); // status = unread
- press_delete(mc);
- assert_not_equals(curMessage, select_click_row(0));
- check_status(
- null,
- offset,
- statusOffset,
- Ci.nsMsgMessageFlags.Read + Ci.nsMsgMessageFlags.Expunged
- );
-
- // 4 messages in the folder.
- curMessage = select_click_row(0);
- check_status(curMessage, null, null, 0); // status = unread
-
- // Make sure we can mark all read with >0 messages unread.
- right_click_on_row(0);
- mc.click_menus_in_sequence(mc.e("mailContext"), [
- { id: "mailContext-mark" },
- { id: "mailContext-markAllRead" },
- ]);
-
- // All the 4 messages should now be read.
- assert_true(curMessage.isRead, "Message should have been marked Read!");
- check_status(curMessage, null, null, Ci.nsMsgMessageFlags.Read);
- curMessage = select_click_row(1);
- assert_true(curMessage.isRead, "Message should have been marked Read!");
- check_status(curMessage, null, null, Ci.nsMsgMessageFlags.Read);
- curMessage = select_click_row(2);
- assert_true(curMessage.isRead, "Message should have been marked Read!");
- check_status(curMessage, null, null, Ci.nsMsgMessageFlags.Read);
- curMessage = select_click_row(3);
- assert_true(curMessage.isRead, "Message should have been marked Read!");
- check_status(curMessage, null, null, Ci.nsMsgMessageFlags.Read);
-
- // Let's have the last message unread.
- right_click_on_row(3);
- mc.click_menus_in_sequence(mc.e("mailContext"), [
- { id: "mailContext-mark" },
- { id: "mailContext-markUnread" },
- ]);
- assert_false(curMessage.isRead, "Message should have not been marked Read!");
- check_status(curMessage, null, null, 0);
-}
-
-function test_mark_messages_flagged() {
- // Mark a message with the star.
- let curMessage = select_click_row(1);
- right_click_on_row(1);
- mc.click_menus_in_sequence(mc.e("mailContext"), [
- { id: "mailContext-mark" },
- { id: "mailContext-markFlagged" },
- ]);
- assert_true(curMessage.isFlagged, "Message should have been marked Flagged!");
- check_status(
- curMessage,
- null,
- null,
- Ci.nsMsgMessageFlags.Read + Ci.nsMsgMessageFlags.Marked
- );
-}
-
-function subtest_check_queued_message() {
- // Always check the last message in the Outbox for the correct flag.
- be_in_folder(gOutbox);
- let queued = gOutbox.messages;
- while (queued.hasMoreElements()) {
- let msg = queued.getNext().QueryInterface(Ci.nsIMsgDBHdr);
- if (!queued.hasMoreElements()) {
- check_status(msg, null, null, Ci.nsMsgMessageFlags.Queued);
- }
- }
-}
-
-/**
- * Create a reply or forward of a message and queue it for sending later.
- *
- * @param aMsgRow Row index of message in Inbox that is to be replied/forwarded.
- * @param aReply true = reply, false = forward.
- */
-function reply_forward_message(aMsgRow, aReply) {
- be_in_folder(gInbox);
- select_click_row(aMsgRow);
- let cwc;
- if (aReply) {
- // Reply to the message.
- cwc = open_compose_with_reply();
- } else {
- // Forward the message.
- cwc = open_compose_with_forward();
- // Type in some recipient.
- setup_msg_contents(cwc, "somewhere@host.invalid", "", "");
- }
-
- // Send it later.
- plan_for_window_close(cwc);
- // Ctrl+Shift+Return = Send Later
- cwc.keypress(cwc.eid("content-frame"), "VK_RETURN", {
- shiftKey: true,
- accelKey: true,
- });
- wait_for_window_close(cwc);
-
- subtest_check_queued_message();
-
- // Now this is hacky. We can't get the message to be sent out of TB because there
- // is no fake SMTP server support yet.
- // But we know that upon real sending of the message, the code would/should call
- // .addMessageDispositionState(). So call it directly and check the expected
- // flags were set. This is risky as the real code could change and call
- // a different function and the purpose of this test would be lost.
- be_in_folder(gInbox);
- let curMessage = select_click_row(aMsgRow);
- let disposition = aReply
- ? gInbox.nsMsgDispositionState_Replied
- : gInbox.nsMsgDispositionState_Forwarded;
- gInbox.addMessageDispositionState(curMessage, disposition);
-}
-
-test_mark_messages_replied.__force_skip__ = true; // See bug 1602584.
-function test_mark_messages_replied() {
- reply_forward_message(2, true);
- let curMessage = select_click_row(2);
- check_status(
- curMessage,
- null,
- null,
- Ci.nsMsgMessageFlags.Replied + Ci.nsMsgMessageFlags.Read
- );
-}
-
-test_mark_messages_forwarded.__force_skip__ = true; // See bug 1602584.
-function test_mark_messages_forwarded() {
- be_in_folder(gInbox);
- // Forward a clean message.
- reply_forward_message(3, false);
- let curMessage = select_click_row(3);
- check_status(curMessage, null, null, Ci.nsMsgMessageFlags.Forwarded);
-
- // Forward a message that is read and already replied to.
- reply_forward_message(2, false);
- curMessage = select_click_row(2);
- check_status(
- curMessage,
- null,
- null,
- Ci.nsMsgMessageFlags.Forwarded +
- Ci.nsMsgMessageFlags.Replied +
- Ci.nsMsgMessageFlags.Read
- );
-}
-
-function teardownModule(module) {
- Services.prefs.setBoolPref("mailnews.mark_message_read.auto", gAutoRead);
- // Clear all the created messages.
- be_in_folder(gInbox.parent);
- empty_folder(gInbox);
- empty_folder(gOutbox);
- gInbox.server.rootFolder.emptyTrash(null, null);
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-display/test-message-commands.js
+++ /dev/null
@@ -1,644 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * This tests various commands on messages. This is primarily for commands
- * that can't be tested with xpcshell tests because they're handling in the
- * front end - which is why Archive is the only command currently tested.
- */
-
-"use strict";
-
-var { wait_for_content_tab_load } = ChromeUtils.import(
- "resource://testing-common/mozmill/ContentTabHelpers.jsm"
-);
-var {
- add_sets_to_folders,
- archive_selected_messages,
- assert_equals,
- assert_false,
- assert_not_equals,
- assert_selected_and_displayed,
- assert_true,
- be_in_folder,
- close_popup,
- collapse_all_threads,
- create_folder,
- create_thread,
- make_display_threaded,
- make_display_unthreaded,
- make_new_sets_in_folder,
- mc,
- press_delete,
- right_click_on_row,
- select_click_row,
- select_control_click_row,
- select_shift_click_row,
- wait_for_popup_to_open,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { plan_for_modal_dialog, wait_for_modal_dialog } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-var { MailUtils } = ChromeUtils.import("resource:///modules/MailUtils.jsm");
-
-var unreadFolder, shiftDeleteFolder, threadDeleteFolder;
-var archiveSrcFolder = null;
-var archiveURI;
-
-var acctMgr;
-var tagArray;
-
-var setupModule = function(module) {
- unreadFolder = create_folder("UnreadFolder");
- shiftDeleteFolder = create_folder("ShiftDeleteFolder");
- threadDeleteFolder = create_folder("ThreadDeleteFolder");
- archiveSrcFolder = create_folder("ArchiveSrc");
-
- make_new_sets_in_folder(unreadFolder, [{ count: 2 }]);
- make_new_sets_in_folder(shiftDeleteFolder, [{ count: 3 }]);
- add_sets_to_folders(
- [threadDeleteFolder],
- [create_thread(3), create_thread(3), create_thread(3)]
- );
-
- // Create messages from 20 different months, which will mean 2 different
- // years as well.
- make_new_sets_in_folder(archiveSrcFolder, [
- { count: 20, age_incr: { weeks: 5 } },
- ]);
-
- tagArray = MailServices.tags.getAllTags();
-};
-
-/**
- * Ensures that all messages have a particular read status
- * @param messages an array of nsIMsgDBHdrs to check
- * @param read true if the messages should be marked read, false otherwise
- */
-function check_read_status(messages, read) {
- function read_str(read) {
- return read ? "read" : "unread";
- }
-
- for (let i = 0; i < messages.length; i++) {
- assert_true(
- messages[i].isRead == read,
- "Message marked as " +
- read_str(messages[i].isRead) +
- ", expected " +
- read_str(read)
- );
- }
-}
-
-/**
- * Ensures that the mark read/unread menu items are enabled/disabled properly
- * @param index the row in the thread pane of the message to query
- * @param canMarkRead true if the mark read item should be enabled
- * @param canMarkUnread true if the mark unread item should be enabled
- */
-function check_read_menuitems(index, canMarkRead, canMarkUnread) {
- right_click_on_row(index);
- wait_for_popup_to_open(mc.e("mailContext"));
- mc.click_menus_in_sequence(mc.e("mailContext"), [{ id: "mailContext-mark" }]);
-
- let readEnabled = !mc.e("mailContext-markRead").disabled;
- let unreadEnabled = !mc.e("mailContext-markUnread").disabled;
-
- assert_true(
- readEnabled == canMarkRead,
- "Mark read menu item " +
- (canMarkRead ? "dis" : "en") +
- "abled when it shouldn't be!"
- );
-
- assert_true(
- unreadEnabled == canMarkUnread,
- "Mark unread menu item " +
- (canMarkUnread ? "dis" : "en") +
- "abled when it shouldn't be!"
- );
-}
-
-function enable_archiving(enabled) {
- Services.prefs.setBoolPref("mail.identity.default.archive_enabled", enabled);
-}
-
-/**
- * Mark a message read or unread via the context menu
- * @param index the row in the thread pane of the message to mark read/unread
- * @param read true the message should be marked read, false otherwise
- */
-function mark_read_via_menu(index, read) {
- let menuItem = read ? "mailContext-markRead" : "mailContext-markUnread";
- right_click_on_row(index);
- wait_for_popup_to_open(mc.e("mailContext"));
- mc.click_menus_in_sequence(mc.e("mailContext"), [
- { id: "mailContext-mark" },
- { id: menuItem },
- ]);
- close_popup(mc, mc.eid("mailContext"));
-}
-
-function test_mark_one_read() {
- be_in_folder(unreadFolder);
- let curMessage = select_click_row(0);
-
- curMessage.markRead(false);
- mark_read_via_menu(0, true);
- check_read_status([curMessage], true);
-}
-
-function test_mark_one_unread() {
- be_in_folder(unreadFolder);
- let curMessage = select_click_row(0);
-
- curMessage.markRead(true);
- mark_read_via_menu(0, false);
- check_read_status([curMessage], false);
-}
-
-function test_mark_n_read() {
- be_in_folder(unreadFolder);
- select_click_row(0);
- let curMessages = select_shift_click_row(1);
-
- for (let i = 0; i < curMessages.length; i++) {
- curMessages[i].markRead(false);
- }
- mark_read_via_menu(0, true);
- check_read_status(curMessages, true);
-}
-
-function test_mark_n_unread() {
- be_in_folder(unreadFolder);
- select_click_row(0);
- let curMessages = select_shift_click_row(1);
-
- for (let i = 0; i < curMessages.length; i++) {
- curMessages[i].markRead(true);
- }
- mark_read_via_menu(0, false);
- check_read_status(curMessages, false);
-}
-
-function test_mark_n_read_mixed() {
- be_in_folder(unreadFolder);
- select_click_row(0);
- let curMessages = select_shift_click_row(1);
-
- curMessages[0].markRead(true);
- curMessages[1].markRead(false);
- mark_read_via_menu(0, true);
- check_read_status(curMessages, true);
-
- curMessages[0].markRead(false);
- curMessages[1].markRead(true);
- mark_read_via_menu(0, true);
- check_read_status(curMessages, true);
-}
-
-function test_mark_n_unread_mixed() {
- be_in_folder(unreadFolder);
- select_click_row(0);
- let curMessages = select_shift_click_row(1);
-
- curMessages[0].markRead(false);
- curMessages[1].markRead(true);
- mark_read_via_menu(0, false);
- check_read_status(curMessages, false);
-
- curMessages[0].markRead(true);
- curMessages[1].markRead(false);
- mark_read_via_menu(0, false);
- check_read_status(curMessages, false);
-}
-
-function test_toggle_read() {
- be_in_folder(unreadFolder);
- let curMessage = select_click_row(0);
-
- curMessage.markRead(false);
- mc.keypress(null, "m", {});
- check_read_status([curMessage], true);
-}
-
-function test_toggle_unread() {
- be_in_folder(unreadFolder);
- let curMessage = select_click_row(0);
-
- curMessage.markRead(true);
- mc.keypress(null, "m", {});
- check_read_status([curMessage], false);
-}
-
-function test_toggle_mixed() {
- be_in_folder(unreadFolder);
- select_click_row(0);
- let curMessages = select_shift_click_row(1);
-
- curMessages[0].markRead(false);
- curMessages[1].markRead(true);
- mc.keypress(null, "m", {});
- check_read_status(curMessages, true);
-
- curMessages[0].markRead(true);
- curMessages[1].markRead(false);
- mc.keypress(null, "m", {});
- check_read_status(curMessages, false);
-}
-
-function test_mark_menu_read() {
- be_in_folder(unreadFolder);
- let curMessage = select_click_row(0);
-
- curMessage.markRead(false);
- check_read_menuitems(0, true, false);
-}
-
-function test_mark_menu_unread() {
- be_in_folder(unreadFolder);
- let curMessage = select_click_row(0);
-
- curMessage.markRead(true);
- check_read_menuitems(0, false, true);
-}
-
-function test_mark_menu_mixed() {
- be_in_folder(unreadFolder);
- select_click_row(0);
- let curMessages = select_shift_click_row(1);
-
- curMessages[0].markRead(false);
- curMessages[1].markRead(true);
-
- check_read_menuitems(0, true, true);
-}
-
-function test_mark_all_read() {
- be_in_folder(unreadFolder);
- let curMessage = select_click_row(0);
- curMessage.markRead(false);
-
- // Make sure we can mark all read with >0 messages unread.
- right_click_on_row(0);
- wait_for_popup_to_open(mc.e("mailContext"));
- mc.click_menus_in_sequence(mc.e("mailContext"), [
- { id: "mailContext-mark" },
- { id: "mailContext-markAllRead" },
- ]);
- close_popup(mc, mc.eid("mailContext"));
-
- assert_true(curMessage.isRead, "Message should have been marked read!");
-
- // Make sure we can't mark all read, now that all messages are already read.
- right_click_on_row(0);
- wait_for_popup_to_open(mc.e("mailContext"));
- mc.click_menus_in_sequence(mc.e("mailContext"), [{ id: "mailContext-mark" }]);
-
- let allReadDisabled = mc.e("mailContext-markAllRead").disabled;
- assert_true(allReadDisabled, "Mark All Read menu item should be disabled!");
-}
-
-function test_shift_delete_prompt() {
- be_in_folder(shiftDeleteFolder);
- let curMessage = select_click_row(0);
-
- // First, try shift-deleting and then cancelling at the prompt.
- Services.prefs.setBoolPref("mail.warn_on_shift_delete", true);
- plan_for_modal_dialog("commonDialogWindow", function(controller) {
- controller.window.document
- .querySelector("dialog")
- .getButton("cancel")
- .doCommand();
- });
- // We don't use press_delete here because we're not actually deleting this
- // time!
- mc.keypress(null, "VK_DELETE", { shiftKey: true });
- wait_for_modal_dialog("commonDialogWindow");
- // Make sure we didn't actually delete the message.
- assert_equals(curMessage, select_click_row(0));
-
- // Second, try shift-deleting and then accepting the deletion.
- plan_for_modal_dialog("commonDialogWindow", function(controller) {
- controller.window.document
- .querySelector("dialog")
- .getButton("accept")
- .doCommand();
- });
- press_delete(mc, { shiftKey: true });
- wait_for_modal_dialog("commonDialogWindow");
- // Make sure we really did delete the message.
- assert_not_equals(curMessage, select_click_row(0));
-
- // Finally, try shift-deleting when we turned off the prompt.
- Services.prefs.setBoolPref("mail.warn_on_shift_delete", false);
- curMessage = select_click_row(0);
- press_delete(mc, { shiftKey: true });
- wait_for_modal_dialog("commonDialogWindow");
- // Make sure we really did delete the message.
- assert_not_equals(curMessage, select_click_row(0));
-
- Services.prefs.clearUserPref("mail.warn_on_shift_delete");
-}
-
-function test_thread_delete_prompt() {
- be_in_folder(threadDeleteFolder);
- make_display_threaded();
- collapse_all_threads();
-
- let curMessage = select_click_row(0);
- // First, try deleting and then cancelling at the prompt.
- Services.prefs.setBoolPref("mail.warn_on_collapsed_thread_operation", true);
- plan_for_modal_dialog("commonDialogWindow", function(controller) {
- controller.window.document
- .querySelector("dialog")
- .getButton("cancel")
- .doCommand();
- });
- // We don't use press_delete here because we're not actually deleting this
- // time!
- mc.keypress(null, "VK_DELETE", {});
- wait_for_modal_dialog("commonDialogWindow");
- // Make sure we didn't actually delete the message.
- assert_equals(curMessage, select_click_row(0));
-
- // Second, try deleting and then accepting the deletion.
- plan_for_modal_dialog("commonDialogWindow", function(controller) {
- controller.window.document
- .querySelector("dialog")
- .getButton("accept")
- .doCommand();
- });
- press_delete(mc);
- wait_for_modal_dialog("commonDialogWindow");
- // Make sure we really did delete the message.
- assert_not_equals(curMessage, select_click_row(0));
-
- // Finally, try shift-deleting when we turned off the prompt.
- Services.prefs.setBoolPref("mail.warn_on_collapsed_thread_operation", false);
- curMessage = select_click_row(0);
- press_delete(mc);
- wait_for_modal_dialog("commonDialogWindow");
- // Make sure we really did delete the message.
- assert_not_equals(curMessage, select_click_row(0));
-
- Services.prefs.clearUserPref("mail.warn_on_collapsed_thread_operation");
-}
-
-function test_yearly_archive() {
- yearly_archive(false);
-}
-
-function yearly_archive(keep_structure) {
- be_in_folder(archiveSrcFolder);
- make_display_unthreaded();
- mc.folderDisplay.view.sort(
- Ci.nsMsgViewSortType.byDate,
- Ci.nsMsgViewSortOrder.ascending
- );
-
- let identity = MailServices.accounts.getFirstIdentityForServer(
- mc.folderDisplay.view.dbView.getMsgHdrAt(0).folder.server
- );
- identity.archiveGranularity = Ci.nsIMsgIdentity.perYearArchiveFolders;
- // We need to get all the info about the messages before we do the archive,
- // because deleting the headers could make extracting values from them fail.
- let firstMsgHdr = mc.folderDisplay.view.dbView.getMsgHdrAt(0);
- let lastMsgHdr = mc.folderDisplay.view.dbView.getMsgHdrAt(12);
- let firstMsgHdrMsgId = firstMsgHdr.messageId;
- let lastMsgHdrMsgId = lastMsgHdr.messageId;
- let firstMsgDate = new Date(firstMsgHdr.date / 1000);
- let firstMsgYear = firstMsgDate.getFullYear().toString();
- let lastMsgDate = new Date(lastMsgHdr.date / 1000);
- let lastMsgYear = lastMsgDate.getFullYear().toString();
-
- select_click_row(0);
- select_control_click_row(12);
-
- // Press the archive key. The results should go into two separate years.
- archive_selected_messages();
-
- // Figure out where the messages should have gone.
- let archiveRoot = "mailbox://nobody@Local%20Folders/Archives";
- let firstArchiveUri = archiveRoot + "/" + firstMsgYear;
- let lastArchiveUri = archiveRoot + "/" + lastMsgYear;
- if (keep_structure) {
- firstArchiveUri += "/ArchiveSrc";
- lastArchiveUri += "/ArchiveSrc";
- }
- let firstArchiveFolder = MailUtils.getOrCreateFolder(firstArchiveUri);
- let lastArchiveFolder = MailUtils.getOrCreateFolder(lastArchiveUri);
- be_in_folder(firstArchiveFolder);
- assert_true(
- mc.dbView.getMsgHdrAt(0).messageId == firstMsgHdrMsgId,
- "Message should have been archived to " +
- firstArchiveUri +
- ", but it isn't present there"
- );
- be_in_folder(lastArchiveFolder);
-
- assert_true(
- mc.dbView.getMsgHdrAt(0).messageId == lastMsgHdrMsgId,
- "Message should have been archived to " +
- lastArchiveUri +
- ", but it isn't present there"
- );
-}
-
-function test_monthly_archive() {
- enable_archiving(true);
- monthly_archive(false);
-}
-
-function monthly_archive(keep_structure) {
- be_in_folder(archiveSrcFolder);
- let identity = MailServices.accounts.getFirstIdentityForServer(
- mc.folderDisplay.view.dbView.getMsgHdrAt(0).folder.server
- );
- identity.archiveGranularity = Ci.nsIMsgIdentity.perMonthArchiveFolders;
- select_click_row(0);
- select_control_click_row(1);
-
- let firstMsgHdr = mc.folderDisplay.view.dbView.getMsgHdrAt(0);
- let lastMsgHdr = mc.folderDisplay.view.dbView.getMsgHdrAt(1);
- let firstMsgHdrMsgId = firstMsgHdr.messageId;
- let lastMsgHdrMsgId = lastMsgHdr.messageId;
- let firstMsgDate = new Date(firstMsgHdr.date / 1000);
- let firstMsgYear = firstMsgDate.getFullYear().toString();
- let firstMonthFolderName =
- firstMsgYear +
- "-" +
- (firstMsgDate.getMonth() + 1).toString().padStart(2, "0");
- let lastMsgDate = new Date(lastMsgHdr.date / 1000);
- let lastMsgYear = lastMsgDate.getFullYear().toString();
- let lastMonthFolderName =
- lastMsgYear +
- "-" +
- (lastMsgDate.getMonth() + 1).toString().padStart(2, "0");
-
- // Press the archive key. The results should go into two separate months.
- archive_selected_messages();
-
- // Figure out where the messages should have gone.
- let archiveRoot = "mailbox://nobody@Local%20Folders/Archives";
- let firstArchiveUri =
- archiveRoot + "/" + firstMsgYear + "/" + firstMonthFolderName;
- let lastArchiveUri =
- archiveRoot + "/" + lastMsgYear + "/" + lastMonthFolderName;
- if (keep_structure) {
- firstArchiveUri += "/ArchiveSrc";
- lastArchiveUri += "/ArchiveSrc";
- }
- let firstArchiveFolder = MailUtils.getOrCreateFolder(firstArchiveUri);
- let lastArchiveFolder = MailUtils.getOrCreateFolder(lastArchiveUri);
- be_in_folder(firstArchiveFolder);
- assert_true(
- mc.dbView.getMsgHdrAt(0).messageId == firstMsgHdrMsgId,
- "Message should have been archived to Local Folders/" +
- firstMsgYear +
- "/" +
- firstMonthFolderName +
- "/Archives, but it isn't present there"
- );
- be_in_folder(lastArchiveFolder);
- assert_true(
- mc.dbView.getMsgHdrAt(0).messageId == lastMsgHdrMsgId,
- "Message should have been archived to Local Folders/" +
- lastMsgYear +
- "/" +
- lastMonthFolderName +
- "/Archives, but it isn't present there"
- );
-}
-
-function test_folder_structure_archiving() {
- enable_archiving(true);
- Services.prefs.setBoolPref(
- "mail.identity.default.archive_keep_folder_structure",
- true
- );
- monthly_archive(true);
- yearly_archive(true);
-}
-
-function test_selection_after_archive() {
- enable_archiving(true);
- be_in_folder(archiveSrcFolder);
- let identity = MailServices.accounts.getFirstIdentityForServer(
- mc.folderDisplay.view.dbView.getMsgHdrAt(0).folder.server
- );
- identity.archiveGranularity = Ci.nsIMsgIdentity.perMonthArchiveFolders;
- // We had a bug where we would always select the 0th message after an
- // archive, so test that we'll actually select the next remaining message
- // by archiving rows 1 & 2 and verifying that the 3rd message gets selected.
- let hdrToSelect = select_click_row(3);
- select_click_row(1);
- select_control_click_row(2);
- archive_selected_messages();
- assert_selected_and_displayed(hdrToSelect);
-}
-
-function test_disabled_archive() {
- enable_archiving(false);
- be_in_folder(archiveSrcFolder);
-
- // test single message
- let current = select_click_row(0);
- mc.keypress(null, "a", {});
- assert_selected_and_displayed(current);
-
- assert_true(
- mc.e("hdrArchiveButton").disabled,
- "Archive button should be disabled when archiving is disabled!"
- );
-
- // test message summaries
- select_click_row(0);
- current = select_shift_click_row(2);
- mc.keypress(null, "a", {});
- assert_selected_and_displayed(current);
-
- let htmlframe = mc.e("multimessage");
- let archiveBtn = htmlframe.contentDocument.getElementById("hdrArchiveButton");
- assert_true(
- archiveBtn.collapsed,
- "Multi-message archive button should be disabled when " +
- "archiving is disabled!"
- );
-
- // test message summaries with "large" selection
- mc.folderDisplay.MAX_COUNT_FOR_CAN_ARCHIVE_CHECK = 1;
- select_click_row(0);
- current = select_shift_click_row(2);
- mc.keypress(null, "a", {});
- assert_selected_and_displayed(current);
- mc.folderDisplay.MAX_COUNT_FOR_CAN_ARCHIVE_CHECK = 100;
-
- htmlframe = mc.e("multimessage");
- archiveBtn = htmlframe.contentDocument.getElementById("hdrArchiveButton");
- assert_true(
- archiveBtn.collapsed,
- "Multi-message archive button should be disabled when " +
- "archiving is disabled!"
- );
-}
-
-function check_tag_in_message(message, tag, isSet) {
- let tagSet = message
- .getStringProperty("keywords")
- .split(" ")
- .includes(tag.key);
- if (isSet) {
- assert_true(tagSet, "Tag '" + tag.name + "' expected on message!");
- } else {
- assert_false(tagSet, "Tag '" + tag.name + "' not expected on message!");
- }
-}
-
-function test_tag_keys() {
- be_in_folder(unreadFolder);
- let curMessage = select_click_row(0);
-
- mc.keypress(null, "1", {});
- check_tag_in_message(curMessage, tagArray[0], true);
-
- mc.keypress(null, "2", {});
- check_tag_in_message(curMessage, tagArray[0], true);
- check_tag_in_message(curMessage, tagArray[1], true);
-
- mc.keypress(null, "0", {});
- check_tag_in_message(curMessage, tagArray[0], false);
- check_tag_in_message(curMessage, tagArray[1], false);
-}
-
-function test_tag_keys_disabled_in_content_tab() {
- be_in_folder(unreadFolder);
- let curMessage = select_click_row(0);
-
- mc.window.openAddonsMgr("addons://list/theme");
- mc.sleep(0);
-
- let tab = mc.tabmail.currentTabInfo;
- wait_for_content_tab_load(tab, "about:addons", 15000);
-
- // Make sure pressing the "1" key in a content tab doesn't tag a message
- check_tag_in_message(curMessage, tagArray[0], false);
- mc.keypress(null, "1", {});
- check_tag_in_message(curMessage, tagArray[0], false);
-
- mc.tabmail.closeTab(tab);
-}
-
-function teardownModule() {
- // Make sure archiving is enabled at the end
- enable_archiving(true);
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-display/test-message-pane-visibility.js
+++ /dev/null
@@ -1,238 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test that the message pane collapses properly, stays collapsed amongst tab
- * changes, and that persistence works (to a first approximation).
- */
-
-"use strict";
-
-var {
- assert_message_pane_hidden,
- assert_message_pane_visible,
- be_in_folder,
- close_tab,
- create_folder,
- make_new_sets_in_folder,
- mc,
- open_folder_in_new_tab,
- open_selected_message_in_new_tab,
- select_click_row,
- switch_tab,
- toggle_message_pane,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var folder;
-
-function setupModule(module) {
- folder = create_folder("MessagePaneVisibility");
- make_new_sets_in_folder(folder, [{ count: 3 }]);
-}
-
-/**
- * By default, the message pane should be visible. Make sure that this state of
- * affairs is correct in terms of menu options, splitters, etc.
- */
-function test_message_pane_visible_state_is_right() {
- be_in_folder(folder);
- assert_message_pane_visible();
-}
-
-/**
- * Make sure the account central page does not have the message pane splitter
- * visible. This should go elsewhere once we have more tests involving
- * account central. (Layout tests?)
- */
-function test_account_central_has_no_splitter() {
- be_in_folder(folder.rootFolder);
- assert_message_pane_hidden(true);
- be_in_folder(folder);
-}
-
-/**
- * Toggle the message off.
- */
-function test_toggle_message_pane_off() {
- toggle_message_pane();
- assert_message_pane_hidden();
-}
-
-/**
- * Toggle the message pane on.
- */
-function test_toggle_message_pane_on() {
- toggle_message_pane();
- assert_message_pane_visible();
-}
-
-/**
- * Make sure that the message tab isn't broken by being invoked from a folder tab
- * with a collapsed message pane.
- */
-function test_collapsed_message_pane_does_not_break_message_tab() {
- be_in_folder(folder);
-
- // - toggle message pane off
- toggle_message_pane();
- assert_message_pane_hidden();
-
- // - open message tab, make sure the message pane is visible
- select_click_row(0);
- let tabMessage = open_selected_message_in_new_tab();
- assert_message_pane_visible(true);
-
- // - close the tab, sanity check the transition was okay
- close_tab(tabMessage);
- assert_message_pane_hidden();
-
- // - restore the state...
- toggle_message_pane();
-}
-
-/**
- * Make sure that switching to message tabs or folder pane tabs with a different
- * message pane state does not break. This test should cover all transition
- * states.
- */
-function test_message_pane_is_sticky() {
- let tabFolderA = be_in_folder(folder);
- assert_message_pane_visible();
-
- // [folder+ => (new) message]
- select_click_row(0);
- let tabMessage = open_selected_message_in_new_tab();
- assert_message_pane_visible(true);
-
- // [message => folder+]
- switch_tab(tabFolderA);
- assert_message_pane_visible();
-
- // [folder+ => (new) folder+]
- let tabFolderB = open_folder_in_new_tab(folder);
- assert_message_pane_visible();
-
- // [folder pane toggle + => -]
- toggle_message_pane();
- assert_message_pane_hidden();
-
- // [folder- => folder+]
- switch_tab(tabFolderA);
- assert_message_pane_visible();
-
- // (redundant) [ folder pane toggle + => -]
- toggle_message_pane();
- assert_message_pane_hidden();
-
- // [folder- => message]
- switch_tab(tabMessage);
- assert_message_pane_visible(true);
-
- // [message => folder-]
- close_tab(tabMessage);
- assert_message_pane_hidden();
-
- // [folder- => (new) folder-]
- // (we are testing inheritance here)
- let tabFolderC = open_folder_in_new_tab(folder);
- assert_message_pane_hidden();
-
- // [folder- => folder-]
- close_tab(tabFolderC);
- // the tab we are on now doesn't matter, so we don't care
- assert_message_pane_hidden();
- switch_tab(tabFolderB);
-
- // [ folder pane toggle - => + ]
- toggle_message_pane();
- assert_message_pane_visible();
-
- // [folder+ => folder-]
- close_tab(tabFolderB);
- assert_message_pane_hidden();
-
- // (redundant) [ folder pane toggle - => + ]
- toggle_message_pane();
- assert_message_pane_visible();
-}
-
-/**
- * Test that if we serialize and restore the tabs that the message pane is in
- * the expected collapsed/non-collapsed state. Because of the special "first
- * tab" situation, we need to do this twice to test each case for the first
- * tab. For additional thoroughness we also flip the state we have the other
- * tabs be in.
- */
-function test_message_pane_persistence_generally_works() {
- be_in_folder(folder);
-
- // helper to open tabs with the message pane in the desired states (1 for
- // visible, 0 for hidden)
- function openTabs(aConfig) {
- let curState;
- for (let [iTab, messagePaneVisible] of aConfig.entries()) {
- if (iTab == 0) {
- curState = messagePaneVisible;
- } else {
- open_folder_in_new_tab(folder);
- if (curState != messagePaneVisible) {
- toggle_message_pane();
- curState = messagePaneVisible;
- }
- }
- }
- }
-
- // close everything but the first tab.
- function closeTabs() {
- while (mc.tabmail.tabInfo.length > 1) {
- close_tab(1);
- }
- }
-
- function verifyTabs(aConfig) {
- for (let [iTab, messagePaneVisible] of aConfig.entries()) {
- switch_tab(iTab);
- dump(" checking tab: " + iTab + "\n");
- if (messagePaneVisible) {
- assert_message_pane_visible();
- } else {
- assert_message_pane_hidden();
- }
- }
- }
-
- let configs = [
- // 1st time: [+ - - + +]
- [1, 0, 0, 1, 1],
- // 2nd time: [- + + - -]
- [0, 1, 1, 0, 0],
- ];
- for (let config of configs) {
- openTabs(config);
- verifyTabs(config); // make sure openTabs did its job right
-
- // Switch to the first tab, so that we don't cause a double message load
- // while restoring tabs (one by the first tab, one by the currently selected
- // one). This is fine because we only restore tabs at startup, and we know
- // that we don't select a message at startup.
- // XXX This should probably be fixed properly, though.
- switch_tab(0);
-
- let state = mc.tabmail.persistTabs();
- closeTabs();
- // toggle the state for the current tab so we can be sure that it knows how
- // to change things.
- toggle_message_pane();
- mc.tabmail.restoreTabs(state);
- verifyTabs(config);
- closeTabs();
-
- // toggle the first tab again. This sets - properly for the second pass and
- // restores it to + for when we are done.
- toggle_message_pane();
- }
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-display/test-message-reloads.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test that message reloads happen properly when the message pane is hidden,
- * and then made visible again.
- */
-
-"use strict";
-
-var {
- assert_message_pane_hidden,
- assert_message_pane_visible,
- assert_selected_and_displayed,
- be_in_folder,
- close_tab,
- create_folder,
- make_new_sets_in_folder,
- open_folder_in_new_tab,
- select_click_row,
- switch_tab,
- toggle_message_pane,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var folder;
-
-function setupModule(module) {
- folder = create_folder("MessageReloads");
- make_new_sets_in_folder(folder, [{ count: 1 }]);
-}
-
-function test_message_reloads_work_with_message_pane_toggles() {
- be_in_folder(folder);
-
- assert_message_pane_visible();
- select_click_row(0);
- // Toggle the message pane off, then on
- toggle_message_pane();
- assert_message_pane_hidden();
- toggle_message_pane();
- assert_message_pane_visible();
- // Open a new tab with the same message
- let tab = open_folder_in_new_tab(folder);
- // Toggle the message pane off
- assert_message_pane_visible();
- toggle_message_pane();
- assert_message_pane_hidden();
- // Go back to the first tab, and make sure the message is actually displayed
- switch_tab(0);
- assert_message_pane_visible();
- assert_selected_and_displayed(0);
-
- close_tab(tab);
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-display/test-message-size.js
+++ /dev/null
@@ -1,75 +0,0 @@
-/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test that the size column of in the message list is formatted properly (e.g.
- 0.1 KB, 1.2 KB, 12.3 KB, 123 KB, and likewise for MB and GB).
- */
-
-"use strict";
-
-var {
- add_message_to_folder,
- be_in_folder,
- create_folder,
- create_message,
- mc,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var folder;
-
-function setupModule(module) {
- folder = create_folder("MessageSizeA");
-
- // Create messages with sizes in the byte, KB, and MB ranges.
- let bytemsg = create_message({ body: { body: " " } });
-
- let kbstring = "x ".repeat(1024 / 2);
- let kbmsg = create_message({ body: { body: kbstring } });
-
- let mbstring = kbstring.repeat(1024);
- let mbmsg = create_message({ body: { body: mbstring } });
-
- add_message_to_folder(folder, bytemsg);
- add_message_to_folder(folder, kbmsg);
- add_message_to_folder(folder, mbmsg);
-}
-
-function _help_test_message_size(index, unit) {
- be_in_folder(folder);
-
- // Select the nth message
- let curMessage = select_click_row(index);
- // Look at the size column's data
- let tree = mc.folderDisplay.tree;
- let sizeCol = tree.columns.sizeCol;
- let sizeStr = tree.view.getCellText(index, sizeCol);
-
- // Note: this assumes that the numeric part of the size string is first
- let realSize = curMessage.messageSize;
- let abbrSize = parseFloat(sizeStr);
-
- if (isNaN(abbrSize)) {
- throw new Error("formatted size is not numeric: '" + sizeStr + "'");
- }
- if (Math.abs(realSize / Math.pow(1024, unit) - abbrSize) > 0.5) {
- throw new Error("size mismatch: '" + realSize + "' and '" + sizeStr + "'");
- }
-}
-
-function test_byte_message_size() {
- _help_test_message_size(0, 1);
-}
-
-function test_kb_message_size() {
- _help_test_message_size(1, 1);
-}
-
-function test_mb_message_size() {
- _help_test_message_size(2, 2);
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-display/test-message-window.js
+++ /dev/null
@@ -1,157 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test that we can open and close a standalone message display window from the
- * folder pane.
- */
-
-"use strict";
-
-var {
- add_sets_to_folders,
- assert_selected_and_displayed,
- assert_true,
- be_in_folder,
- create_folder,
- create_thread,
- open_selected_message_in_new_window,
- plan_for_message_display,
- press_delete,
- select_click_row,
- wait_for_message_display_completion,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var {
- plan_for_modal_dialog,
- plan_for_window_close,
- wait_for_modal_dialog,
- wait_for_window_close,
-} = ChromeUtils.import("resource://testing-common/mozmill/WindowHelpers.jsm");
-
-var folderA, folderB;
-var curMessage;
-
-function setupModule(module) {
- folderA = create_folder("MessageWindowA");
- folderB = create_folder("MessageWindowB");
- // create three messages in the folder to display
- let msg1 = create_thread(1);
- let msg2 = create_thread(1);
- let thread1 = create_thread(2);
- let thread2 = create_thread(2);
- add_sets_to_folders([folderA], [msg1, msg2, thread1, thread2]);
- // add two more messages in another folder
- let msg3 = create_thread(1);
- let msg4 = create_thread(1);
- add_sets_to_folders([folderB], [msg3, msg4]);
- folderA.msgDatabase.dBFolderInfo.viewFlags =
- Ci.nsMsgViewFlagsType.kThreadedDisplay;
-}
-
-/** The message window controller. */
-var msgc;
-
-function test_open_message_window() {
- be_in_folder(folderA);
-
- // select the first message
- curMessage = select_click_row(0);
-
- // display it
- msgc = open_selected_message_in_new_window();
- assert_selected_and_displayed(msgc, curMessage);
-}
-
-/**
- * Use the "m" keyboard accelerator to mark a message as read or unread.
- */
-function test_toggle_read() {
- curMessage.markRead(false);
- msgc.keypress(null, "m", {});
- assert_true(curMessage.isRead, "Message should have been marked read!");
-
- msgc.keypress(null, "m", {});
- assert_true(!curMessage.isRead, "Message should have been marked unread!");
-}
-
-/**
- * Use the "f" keyboard accelerator to navigate to the next message,
- * and verify that it is indeed loaded.
- */
-function test_navigate_to_next_message() {
- plan_for_message_display(msgc);
- msgc.keypress(null, "f", {});
- wait_for_message_display_completion(msgc, true);
- assert_selected_and_displayed(msgc, 1);
-}
-
-/**
- * Delete a single message and verify the next message is loaded. This sets
- * us up for the next test, which is delete on a collapsed thread after
- * the previous message was deleted.
- */
-function test_delete_single_message() {
- plan_for_message_display(msgc);
- press_delete(msgc);
- wait_for_message_display_completion(msgc, true);
- assert_selected_and_displayed(msgc, 1);
-}
-
-/**
- * Delete the current message, and verify that it only deletes
- * a single message, not the messages in the collapsed thread
- */
-function test_del_collapsed_thread() {
- press_delete(msgc);
- if (folderA.getTotalMessages(false) != 4) {
- throw new Error("should have only deleted one message");
- }
-}
-
-function subtest_say_yes(cwc) {
- cwc.window.document
- .querySelector("dialog")
- .getButton("accept")
- .doCommand();
-}
-
-/**
- * Hit n enough times to mark all messages in folder A read, and then accept the
- * modal dialog saying that we should move to the next folder. Then, assert that
- * the message displayed in the standalone message window is folder B's first
- * message (since all messages in folder B were unread).
- */
-function test_next_unread() {
- for (let i = 0; i < 3; ++i) {
- plan_for_message_display(msgc);
- msgc.keypress(null, "n", {});
- wait_for_message_display_completion(msgc, true);
- }
-
- plan_for_modal_dialog("commonDialogWindow", subtest_say_yes);
- msgc.keypress(null, "n", {});
- plan_for_message_display(msgc);
- wait_for_modal_dialog("commonDialogWindow");
- wait_for_message_display_completion(msgc, true);
-
- // move to folder B
- be_in_folder(folderB);
-
- // select the first message, and make sure it's not read
- let msg = select_click_row(0);
-
- // make sure we've been displaying the right message
- assert_selected_and_displayed(msgc, msg);
-}
-
-/**
- * Close the window by hitting escape.
- */
-function test_close_message_window() {
- plan_for_window_close(msgc);
- msgc.keypress(null, "VK_ESCAPE", {});
- wait_for_window_close(msgc);
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-display/test-opening-messages-without-a-backing-view.js
+++ /dev/null
@@ -1,225 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test that messages without a backing view are opened correctly. Examples of
- * messages without a backing view are those opened from the command line or
- * desktop search integration results.
- */
-
-"use strict";
-
-var {
- add_to_toolbar,
- assert_message_pane_focused,
- assert_messages_not_in_view,
- assert_number_of_tabs_open,
- assert_selected_and_displayed,
- assert_tab_mode_name,
- assert_tab_titled_from,
- be_in_folder,
- close_message_window,
- close_tab,
- create_folder,
- make_new_sets_in_folder,
- mc,
- plan_for_message_display,
- remove_from_toolbar,
- reset_open_message_behavior,
- set_mail_view,
- set_open_message_behavior,
- switch_tab,
- wait_for_message_display_completion,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { plan_for_new_window, wait_for_new_window } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { MailUtils } = ChromeUtils.import("resource:///modules/MailUtils.jsm");
-var { MailViewConstants } = ChromeUtils.import(
- "resource:///modules/MailViewManager.jsm"
-);
-
-// One folder's enough
-var folder = null;
-
-// A list of the message headers in this folder
-var msgHdrsInFolder = null;
-
-// Number of messages to open for multi-message tests
-var NUM_MESSAGES_TO_OPEN = 5;
-
-function setupModule(module) {
- folder = create_folder("OpeningMessagesNoBackingViewA");
- make_new_sets_in_folder(folder, [{ count: 10 }]);
- // We don't obey mail view persistence unless the view picker is there
- add_to_toolbar(mc.e("mail-bar3"), "mailviews-container");
-}
-
-/**
- * Test opening a single message without a backing view in a new tab.
- */
-function test_open_single_message_without_backing_view_in_tab() {
- set_open_message_behavior("NEW_TAB");
- let folderTab = mc.tabmail.currentTabInfo;
- let preCount = mc.tabmail.tabContainer.allTabs.length;
- be_in_folder(folder);
-
- if (!msgHdrsInFolder) {
- msgHdrsInFolder = [];
- // Make a list of all the message headers in this folder
- for (let i = 0; i < 10; i++) {
- msgHdrsInFolder.push(mc.dbView.getMsgHdrAt(i));
- }
- }
- // Get a reference to a header
- let msgHdr = msgHdrsInFolder[4];
- // Open it
- MailUtils.displayMessage(msgHdr);
- // This is going to trigger a message display in the main 3pane window. Since
- // the message will open in a new tab, we shouldn't
- // plan_for_message_display().
- wait_for_message_display_completion(mc, true);
- // Check that the tab count has increased by 1
- assert_number_of_tabs_open(preCount + 1);
- // Check that the currently displayed tab is a message tab (i.e. our newly
- // opened tab is in the foreground)
- assert_tab_mode_name(null, "message");
- // Check that the message header displayed is the right one
- assert_selected_and_displayed(msgHdr);
- // Check that the message pane is focused
- assert_message_pane_focused();
- // Clean up, close the tab
- close_tab(mc.tabmail.currentTabInfo);
- switch_tab(folderTab);
- reset_open_message_behavior();
-}
-
-/**
- * Test opening multiple messages without backing views in new tabs.
- */
-function test_open_multiple_messages_without_backing_views_in_tabs() {
- set_open_message_behavior("NEW_TAB");
- let folderTab = mc.tabmail.currentTabInfo;
- let preCount = mc.tabmail.tabContainer.allTabs.length;
- be_in_folder(folder);
-
- // Get a reference to a bunch of headers
- let msgHdrs = msgHdrsInFolder.slice(0, NUM_MESSAGES_TO_OPEN);
-
- // Open them
- MailUtils.displayMessages(msgHdrs);
- // This is going to trigger a message display in the main 3pane window. Since
- // the message will open in a new tab, we shouldn't
- // plan_for_message_display().
- wait_for_message_display_completion(mc, true);
- // Check that the tab count has increased by the correct number
- assert_number_of_tabs_open(preCount + NUM_MESSAGES_TO_OPEN);
- // Check that the currently displayed tab is a message tab (i.e. one of our
- // newly opened tabs is in the foreground)
- assert_tab_mode_name(null, "message");
-
- // Now check whether each of the NUM_MESSAGES_TO_OPEN tabs has the correct
- // title
- for (let i = 0; i < NUM_MESSAGES_TO_OPEN; i++) {
- assert_tab_titled_from(mc.tabmail.tabInfo[preCount + i], msgHdrs[i]);
- }
-
- // Check whether each tab has the correct message and whether the message pane
- // is focused in each case, then close it to load the previous tab.
- for (let i = 0; i < NUM_MESSAGES_TO_OPEN; i++) {
- assert_selected_and_displayed(msgHdrs.pop());
- assert_message_pane_focused();
- close_tab(mc.tabmail.currentTabInfo);
- }
- switch_tab(folderTab);
- reset_open_message_behavior();
-}
-
-/**
- * Test opening a message without a backing view in a new window.
- */
-function test_open_message_without_backing_view_in_new_window() {
- set_open_message_behavior("NEW_WINDOW");
- be_in_folder(folder);
-
- // Select a message
- let msgHdr = msgHdrsInFolder[6];
-
- plan_for_new_window("mail:messageWindow");
- // Open it
- MailUtils.displayMessage(msgHdr);
- let msgc = wait_for_new_window("mail:messageWindow");
- wait_for_message_display_completion(msgc, true);
-
- assert_selected_and_displayed(msgc, msgHdr);
- // Clean up, close the window
- close_message_window(msgc);
- reset_open_message_behavior();
-}
-
-/**
- * Test reusing an existing window to open a new message.
- */
-function test_open_message_without_backing_view_in_existing_window() {
- set_open_message_behavior("EXISTING_WINDOW");
- be_in_folder(folder);
-
- // Open up a window
- let firstMsgHdr = msgHdrsInFolder[3];
- plan_for_new_window("mail:messageWindow");
- MailUtils.displayMessage(firstMsgHdr);
- let msgc = wait_for_new_window("mail:messageWindow");
- wait_for_message_display_completion(msgc, true);
-
- // Open another message
- let msgHdr = msgHdrsInFolder[7];
- plan_for_message_display(msgc);
- MailUtils.displayMessage(msgHdr);
- wait_for_message_display_completion(msgc, true);
-
- // Check if our old window displays the message
- assert_selected_and_displayed(msgc, msgHdr);
- // Clean up, close the window
- close_message_window(msgc);
- reset_open_message_behavior();
-}
-
-/**
- * Time to throw a spanner in the works. Set a mail view for the folder that
- * excludes every message.
- */
-function test_filter_out_all_messages() {
- set_mail_view(MailViewConstants.kViewItemTags, "$label1");
- // Make sure all the messages have actually disappeared
- assert_messages_not_in_view(msgHdrsInFolder);
-}
-
-/**
- * Re-run all the tests.
- */
-function test_open_single_message_without_backing_view_in_tab_filtered() {
- test_open_single_message_without_backing_view_in_tab();
-}
-
-function test_open_multiple_messages_without_backing_views_in_tabs_filtered() {
- test_open_multiple_messages_without_backing_views_in_tabs();
-}
-
-function test_open_message_without_backing_view_in_new_window_filtered() {
- test_open_message_without_backing_view_in_new_window();
-}
-
-function test_open_message_without_backing_view_in_existing_window_filtered() {
- test_open_message_without_backing_view_in_existing_window();
-}
-
-/**
- * Good hygiene: remove the view picker from the toolbar.
- */
-function test_cleanup() {
- remove_from_toolbar(mc.e("mail-bar3"), "mailviews-container");
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-display/test-opening-messages.js
+++ /dev/null
@@ -1,242 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test that we open single and multiple messages from the thread pane
- * according to the mail.openMessageBehavior preference, and that we have the
- * correct message headers displayed in whatever we open.
- *
- * Currently tested:
- * - opening single and multiple messages in tabs
- * - opening a single message in a window. (Multiple messages require a fair
- * amount of additional work and are hard to test. We're also assuming here
- * that multiple messages opened in windows are just the same function called
- * repeatedly.)
- * - reusing an existing window to show another message
- */
-
-"use strict";
-
-var {
- assert_equals,
- assert_message_pane_focused,
- assert_number_of_tabs_open,
- assert_selected_and_displayed,
- assert_tab_mode_name,
- assert_tab_titled_from,
- be_in_folder,
- close_message_window,
- close_tab,
- create_folder,
- make_new_sets_in_folder,
- mc,
- open_selected_message,
- open_selected_messages,
- plan_for_message_display,
- reset_open_message_behavior,
- select_click_row,
- select_shift_click_row,
- set_open_message_behavior,
- switch_tab,
- wait_for_message_display_completion,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { plan_for_new_window, wait_for_new_window } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-// One folder's enough
-var folder = null;
-
-// Number of messages to open for multi-message tests
-var NUM_MESSAGES_TO_OPEN = 5;
-
-function setupModule(module) {
- folder = create_folder("OpeningMessagesA");
- make_new_sets_in_folder(folder, [{ count: 10 }]);
-}
-
-/**
- * Test opening a single message in a new tab.
- */
-function test_open_single_message_in_tab() {
- set_open_message_behavior("NEW_TAB");
- let folderTab = mc.tabmail.currentTabInfo;
- let preCount = mc.tabmail.tabContainer.allTabs.length;
- be_in_folder(folder);
- // Select one message
- let msgHdr = select_click_row(1);
- // Open it
- open_selected_message();
- // This is going to trigger a message display in the main 3pane window
- wait_for_message_display_completion(mc);
- // Check that the tab count has increased by 1
- assert_number_of_tabs_open(preCount + 1);
- // Check that the currently displayed tab is a message tab (i.e. our newly
- // opened tab is in the foreground)
- assert_tab_mode_name(null, "message");
- // Check that the message header displayed is the right one
- assert_selected_and_displayed(msgHdr);
- // Check that the message pane is focused
- assert_message_pane_focused();
- // Check that the message pane in a newly opened tab has full height.
- check_message_pane_in_tab_full_height();
- // Clean up, close the tab
- close_tab(mc.tabmail.currentTabInfo);
- switch_tab(folderTab);
- reset_open_message_behavior();
-}
-
-/**
- * Test opening multiple messages in new tabs.
- */
-function test_open_multiple_messages_in_tabs() {
- set_open_message_behavior("NEW_TAB");
- let folderTab = mc.tabmail.currentTabInfo;
- let preCount = mc.tabmail.tabContainer.allTabs.length;
- be_in_folder(folder);
-
- // Select a bunch of messages
- select_click_row(1);
- let selectedMessages = select_shift_click_row(NUM_MESSAGES_TO_OPEN);
- // Open them
- open_selected_messages();
- // This is going to trigger a message display in the main 3pane window
- wait_for_message_display_completion(mc);
- // Check that the tab count has increased by the correct number
- assert_number_of_tabs_open(preCount + NUM_MESSAGES_TO_OPEN);
- // Check that the currently displayed tab is a message tab (i.e. one of our
- // newly opened tabs is in the foreground)
- assert_tab_mode_name(null, "message");
-
- // Now check whether each of the NUM_MESSAGES_TO_OPEN tabs has the correct
- // title
- for (let i = 0; i < NUM_MESSAGES_TO_OPEN; i++) {
- assert_tab_titled_from(
- mc.tabmail.tabInfo[preCount + i],
- selectedMessages[i]
- );
- }
-
- // Check whether each tab has the correct message and whether the message pane
- // is focused in each case, then close it to load the previous tab.
- for (let i = 0; i < NUM_MESSAGES_TO_OPEN; i++) {
- assert_selected_and_displayed(selectedMessages.pop());
- assert_message_pane_focused();
- close_tab(mc.tabmail.currentTabInfo);
- }
- switch_tab(folderTab);
- reset_open_message_behavior();
-}
-
-/**
- * Test opening a message in a new window.
- */
-function test_open_message_in_new_window() {
- set_open_message_behavior("NEW_WINDOW");
- be_in_folder(folder);
-
- // Select a message
- let msgHdr = select_click_row(1);
-
- plan_for_new_window("mail:messageWindow");
- // Open it
- open_selected_message();
- let msgc = wait_for_new_window("mail:messageWindow");
- wait_for_message_display_completion(msgc, true);
-
- assert_selected_and_displayed(msgc, msgHdr);
-
- // Check that the message pane in a newly opened window has full height.
- check_message_pane_in_window_full_height(msgc);
-
- // Clean up, close the window
- close_message_window(msgc);
- reset_open_message_behavior();
-}
-
-/**
- * Test reusing an existing window to open a new message.
- */
-function test_open_message_in_existing_window() {
- set_open_message_behavior("EXISTING_WINDOW");
- be_in_folder(folder);
-
- // Open up a window
- select_click_row(1);
- plan_for_new_window("mail:messageWindow");
- open_selected_message();
- let msgc = wait_for_new_window("mail:messageWindow");
- wait_for_message_display_completion(msgc, true);
-
- // Select another message and open it
- let msgHdr = select_click_row(2);
- plan_for_message_display(msgc);
- open_selected_message();
- wait_for_message_display_completion(msgc, true);
-
- // Check if our old window displays the message
- assert_selected_and_displayed(msgc, msgHdr);
- // Clean up, close the window
- close_message_window(msgc);
- reset_open_message_behavior();
-}
-
-/**
- * Check if the message pane in a new tab has the full height, so no
- * empty box is visible below it.
- */
-
-function check_message_pane_in_tab_full_height() {
- let messagesBoxHeight = mc.e("messagesBox").getBoundingClientRect().height;
- let displayDeckHeight = mc.e("displayDeck").getBoundingClientRect().height;
- let messagePaneBoxWrapperHeight = mc
- .e("messagepaneboxwrapper")
- .getBoundingClientRect().height;
- let notificationBoxHeight = mc
- .e("messenger-notification-footer")
- .getBoundingClientRect().height;
-
- assert_equals(
- messagesBoxHeight,
- displayDeckHeight + messagePaneBoxWrapperHeight + notificationBoxHeight,
- "messages box height (" +
- messagesBoxHeight +
- ") not equal to the sum of displayDeck height (" +
- displayDeckHeight +
- ") and message pane box wrapper height (" +
- messagePaneBoxWrapperHeight +
- ") and message notification box height (" +
- notificationBoxHeight +
- ")"
- );
-}
-
-/**
- * Check if the message pane in a new window has the full height, so no
- * empty box is visible below it.
- */
-
-function check_message_pane_in_window_full_height(aWC) {
- let messengerWindowHeight = aWC.e("messengerWindow").getBoundingClientRect()
- .height;
- let messengerChildren = aWC.e("messengerWindow").children;
- let childrenHeightsSum = 0;
- let childrenHeightsStr = "";
- for (let child of messengerChildren) {
- try {
- let childRect = child.getBoundingClientRect();
- childrenHeightsSum += childRect.height;
- childrenHeightsStr += '"' + child.id + '": ' + childRect.height + ", ";
- } catch (ex) {}
- }
-
- assert_equals(
- Math.round(messengerWindowHeight),
- Math.round(childrenHeightsSum),
- "messenger window height not equal to the sum of children heights: " +
- childrenHeightsStr
- );
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-display/test-pane-focus.js
+++ /dev/null
@@ -1,208 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test that cycling through the focus of the 3pane's panes works correctly.
- */
-
-"use strict";
-
-var {
- add_sets_to_folders,
- assert_equals,
- be_in_folder,
- close_tab,
- collapse_all_threads,
- create_folder,
- create_thread,
- make_display_threaded,
- mc,
- open_selected_message_in_new_tab,
- press_delete,
- select_click_row,
- select_none,
- switch_tab,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var folder;
-
-function setupModule(module) {
- folder = create_folder("PaneFocus");
- let msg1 = create_thread(1);
- let thread = create_thread(3);
- let msg2 = create_thread(1);
- add_sets_to_folders([folder], [msg1, thread, msg2]);
-
- be_in_folder(folder);
- make_display_threaded();
- collapse_all_threads();
-}
-
-/**
- * Get the currently-focused pane in the 3pane. One of the folder pane, thread
- * pane, or message pane (single- or multi-message).
- *
- * @return the focused pane
- */
-function get_focused_pane() {
- let panes = ["threadTree", "folderTree", "messagepane", "multimessage"].map(
- id => mc.e(id)
- );
-
- let currentNode = mc.window.top.document.activeElement;
-
- while (currentNode) {
- if (panes.includes(currentNode)) {
- return currentNode;
- }
-
- currentNode = currentNode.parentNode;
- }
- return null;
-}
-
-/**
- * Check that it's possible to cycle through the 3pane's panes forward and
- * backward.
- *
- * @param multimessage true if the multimessage pane should be active
- */
-function check_pane_cycling(multimessage) {
- let folderPane = mc.e("folderTree");
- let threadPane = mc.e("threadTree");
- let messagePane = mc.e(multimessage ? "multimessage" : "messagepane");
-
- folderPane.focus();
-
- mc.keypress(null, "VK_F6", {});
- assert_equals(threadPane, get_focused_pane());
- mc.keypress(null, "VK_F6", {});
- assert_equals(messagePane, get_focused_pane());
- mc.keypress(null, "VK_F6", {});
- assert_equals(folderPane, get_focused_pane());
-
- mc.keypress(null, "VK_F6", { shiftKey: true });
- assert_equals(messagePane, get_focused_pane());
- mc.keypress(null, "VK_F6", { shiftKey: true });
- assert_equals(threadPane, get_focused_pane());
- mc.keypress(null, "VK_F6", { shiftKey: true });
- assert_equals(folderPane, get_focused_pane());
-}
-
-function test_no_messages_selected() {
- be_in_folder(folder);
-
- // Select nothing
- select_none();
- check_pane_cycling(false);
-}
-
-function test_one_message_selected() {
- be_in_folder(folder);
-
- // Select a message
- select_click_row(0);
- check_pane_cycling(false);
-}
-
-function test_n_messages_selected() {
- be_in_folder(folder);
-
- // Select a thread
- select_click_row(1);
- check_pane_cycling(true);
-}
-
-function test_between_tab_and_single_message() {
- be_in_folder(folder);
- select_click_row(0);
- let tab = open_selected_message_in_new_tab(true);
-
- select_click_row(2);
-
- // First, try swapping back and forth between the tabs when the message
- // pane is focused.
- mc.window.SetFocusMessagePane();
-
- switch_tab(tab);
- assert_equals(mc.e("messagepane"), get_focused_pane());
-
- switch_tab();
- assert_equals(mc.e("messagepane"), get_focused_pane());
-
- switch_tab(tab);
- assert_equals(mc.e("messagepane"), get_focused_pane());
-
- switch_tab();
- assert_equals(mc.e("messagepane"), get_focused_pane());
-
- // Now, focus the folder tree and make sure focus updates properly.
- mc.e("folderTree").focus();
-
- switch_tab(tab);
- assert_equals(mc.e("messagepane"), get_focused_pane());
-
- switch_tab();
- assert_equals(mc.e("folderTree"), get_focused_pane());
-
- close_tab(tab);
-}
-
-function test_between_tab_and_multi_message() {
- be_in_folder(folder);
- select_click_row(0);
- let tab = open_selected_message_in_new_tab(true);
-
- select_click_row(1);
-
- // First, try swapping back and forth between the tabs when the message
- // pane is focused.
- mc.window.SetFocusMessagePane();
-
- switch_tab(tab);
- assert_equals(mc.e("messagepane"), get_focused_pane());
-
- switch_tab();
- assert_equals(mc.e("multimessage"), get_focused_pane());
-
- switch_tab(tab);
- assert_equals(mc.e("messagepane"), get_focused_pane());
-
- switch_tab();
- assert_equals(mc.e("multimessage"), get_focused_pane());
-
- // Now, focus the folder tree and make sure focus updates properly.
- mc.e("folderTree").focus();
-
- switch_tab(tab);
- assert_equals(mc.e("messagepane"), get_focused_pane());
-
- switch_tab();
- assert_equals(mc.e("folderTree"), get_focused_pane());
-
- close_tab(tab);
-}
-
-function test_after_delete() {
- be_in_folder(folder);
- make_display_threaded();
- collapse_all_threads();
-
- // Select a message, then delete it to move to the thread
- select_click_row(0);
- mc.window.SetFocusMessagePane();
- press_delete();
-
- assert_equals(mc.e("multimessage"), get_focused_pane());
-
- // Delete the thread (without warning) to move to a message
- Services.prefs.setBoolPref("mail.warn_on_collapsed_thread_operation", false);
- press_delete();
-
- assert_equals(mc.e("messagepane"), get_focused_pane());
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-display/test-recent-menu.js
+++ /dev/null
@@ -1,167 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * This tests the move/copy to recent folder menus to make sure
- * that they get updated when messages are moved to folders, and
- * don't get updated when we archive.
- */
-
-"use strict";
-
-var {
- archive_selected_messages,
- assert_equals,
- be_in_folder,
- create_folder,
- get_special_folder,
- make_new_sets_in_folder,
- mc,
- press_delete,
- right_click_on_row,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var { MailUtils } = ChromeUtils.import("resource:///modules/MailUtils.jsm");
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-var { fixIterator } = ChromeUtils.import(
- "resource:///modules/iteratorUtils.jsm"
-);
-
-var folder1, folder2;
-var gInitRecentMenuCount;
-
-var setupModule = function(module) {
- // Ensure that there are no updated folders to ensure the recent folder
- // is empty.
- let allFolders = MailServices.accounts.allFolders;
- for (let folder of fixIterator(allFolders, Ci.nsIMsgFolder)) {
- folder.setStringProperty("MRMTime", "0");
- }
-
- // Try to make these folders first in alphabetic order
- folder1 = create_folder("aaafolder1");
- folder2 = create_folder("aaafolder2");
-
- make_new_sets_in_folder(folder1, [{ count: 3 }]);
-};
-
-function test_move_message() {
- be_in_folder(folder1);
- let msgHdr = select_click_row(0);
- // This will cause the initial build of the move recent context menu,
- // which should be empty and disabled.
- right_click_on_row(0);
- let popups = mc.click_menus_in_sequence(
- mc.e("mailContext"),
- [{ id: "mailContext-moveMenu" }, { label: "Recent" }],
- true
- );
- let recentMenu = popups[popups.length - 2].querySelector('[label="Recent"]');
- assert_equals(recentMenu.getAttribute("disabled"), "true");
- gInitRecentMenuCount = recentMenu.itemCount;
- assert_equals(gInitRecentMenuCount, 0);
- mc.close_popup_sequence(popups);
- let array = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
- array.appendElement(msgHdr);
- let copyListener = {
- copyDone: false,
- OnStartCopy() {},
- OnProgress(aProgress, aProgressMax) {},
- SetMessageKey(aKey) {},
- SetMessageId(aMessageId) {},
- OnStopCopy(aStatus) {
- this.copyDone = true;
- },
- };
- MailServices.copy.CopyMessages(
- folder1,
- array,
- folder2,
- true,
- copyListener,
- mc.window.msgWindow,
- true
- );
- mc.waitFor(
- () => copyListener.copyDone,
- "Timeout waiting for copy to complete",
- 10000,
- 100
- );
- // We've moved a message to aaafolder2 - it should appear in recent list now.
- // Clicking the menuitem by label is not localizable, but Recent doesn't have an
- // id we can use.
- right_click_on_row(0);
- popups = mc.click_menus_in_sequence(
- mc.e("mailContext"),
- [{ id: "mailContext-moveMenu" }, { label: "Recent" }],
- true
- );
- let recentChildren = popups[popups.length - 1].children;
- assert_equals(
- recentChildren.length,
- gInitRecentMenuCount + 1,
- "recent menu should have one more child after move"
- );
- assert_equals(
- recentChildren[0].label,
- "aaafolder2",
- "recent menu child should be aaafolder2 after move"
- );
- mc.close_popup_sequence(popups);
-}
-
-function test_delete_message() {
- press_delete(mc);
- // We've deleted a message - we should still just have folder2 in the menu.
- right_click_on_row(0);
- let popups = mc.click_menus_in_sequence(
- mc.e("mailContext"),
- [{ id: "mailContext-moveMenu" }, { label: "Recent" }],
- true
- );
- let recentChildren = popups[popups.length - 1].children;
- assert_equals(
- recentChildren.length,
- gInitRecentMenuCount + 1,
- "delete shouldn't add anything to recent menu"
- );
- assert_equals(
- recentChildren[0].label,
- "aaafolder2",
- "recent menu should still be aaafolder2 after delete"
- );
- mc.close_popup_sequence(popups);
-}
-
-function test_archive_message() {
- archive_selected_messages();
- // We've archived a message - we should still just have folder2 in the menu.
- let archive = get_special_folder(Ci.nsMsgFolderFlags.Archive, false, false);
- let archives = archive.descendants;
- be_in_folder(archives.queryElementAt(0, Ci.nsIMsgFolder));
- right_click_on_row(0);
- let popups = mc.click_menus_in_sequence(
- mc.e("mailContext"),
- [{ id: "mailContext-moveMenu" }, { label: "Recent" }],
- true
- );
- let recentChildren = popups[popups.length - 1].children;
- assert_equals(
- recentChildren.length,
- gInitRecentMenuCount + 1,
- "archive shouldn't add anything to recent menu"
- );
- assert_equals(
- recentChildren[0].label,
- "aaafolder2",
- "recent menu should still be aaafolder2 after archive"
- );
- mc.close_popup_sequence(popups);
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-display/test-right-click-middle-click-folders.js
+++ /dev/null
@@ -1,274 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test the many horrors involving right-clicks, middle clicks, and
- * selections... on folders!
- */
-
-"use strict";
-
-var {
- assert_folder_displayed,
- assert_folder_selected,
- assert_folder_selected_and_displayed,
- assert_folders_selected_and_displayed,
- assert_no_folders_selected,
- assert_selected_tab,
- be_in_folder,
- close_popup,
- close_tab,
- create_folder,
- make_new_sets_in_folder,
- mc,
- middle_click_on_folder,
- reset_context_menu_background_tabs,
- right_click_on_folder,
- select_click_folder,
- select_no_folders,
- select_shift_click_folder,
- set_context_menu_background_tabs,
- switch_tab,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var folderA, folderB, folderC;
-
-function setupModule(module) {
- folderA = create_folder("RightClickMiddleClickFoldersA");
- folderB = create_folder("RightClickMiddleClickFoldersB");
- folderC = create_folder("RightClickMiddleClickFoldersC");
-
- // We aren't really interested in the messages the folders contain, but just
- // for appearance's sake, add a message to each folder
-
- make_new_sets_in_folder(folderA, [{ count: 1 }]);
- make_new_sets_in_folder(folderB, [{ count: 1 }]);
- make_new_sets_in_folder(folderC, [{ count: 1 }]);
-}
-
-/**
- * Make sure that a right-click when there is nothing currently selected does
- * not cause us to display something, as well as correctly causing a transient
- * selection to occur.
- */
-function test_right_click_folder_with_nothing_selected() {
- // This should cause folderA to be displayed
- be_in_folder(folderA);
-
- select_no_folders();
- assert_no_folders_selected();
-
- right_click_on_folder(folderB);
- assert_folder_selected(folderB);
- // The displayed folder shouldn't change
- assert_folder_displayed(folderA);
-
- close_popup(mc, mc.eid("folderPaneContext"));
- assert_no_folders_selected();
-}
-
-/**
- * One-thing selected, right-click on something else.
- */
-function test_right_click_folder_with_one_thing_selected() {
- select_click_folder(folderB);
- assert_folder_selected_and_displayed(folderB);
-
- right_click_on_folder(folderA);
- assert_folder_selected(folderA);
- assert_folder_displayed(folderB);
-
- close_popup(mc, mc.eid("folderPaneContext"));
- assert_folder_selected_and_displayed(folderB);
-}
-
-/**
- * Many things selected, right-click on something that is not in that selection.
- */
-function test_right_click_folder_with_many_things_selected() {
- select_click_folder(folderA);
- select_shift_click_folder(folderB);
- assert_folders_selected_and_displayed(folderA, folderB);
-
- right_click_on_folder(folderC);
- assert_folder_selected(folderC);
- assert_folder_displayed(folderA);
-
- close_popup(mc, mc.eid("folderPaneContext"));
- assert_folders_selected_and_displayed(folderA, folderB);
-}
-
-/**
- * One thing selected, right-click on that.
- */
-function test_right_click_folder_on_existing_single_selection() {
- select_click_folder(folderA);
- assert_folders_selected_and_displayed(folderA);
-
- right_click_on_folder(folderA);
- assert_folders_selected_and_displayed(folderA);
-
- close_popup(mc, mc.eid("folderPaneContext"));
- assert_folders_selected_and_displayed(folderA);
-}
-
-/**
- * Many things selected, right-click somewhere in the selection.
- */
-function test_right_click_folder_on_existing_multi_selection() {
- select_click_folder(folderB);
- select_shift_click_folder(folderC);
- assert_folders_selected_and_displayed(folderB, folderC);
-
- right_click_on_folder(folderC);
- assert_folders_selected_and_displayed(folderB, folderC);
-
- close_popup(mc, mc.eid("folderPaneContext"));
- assert_folders_selected_and_displayed(folderB, folderC);
-}
-
-/**
- * Middle clicking should open a message in a tab, but not affect our selection.
- */
-function _middle_click_folder_with_nothing_selected_helper(aBackground) {
- // This should cause folderA to be displayed
- be_in_folder(folderA);
-
- select_no_folders();
- assert_no_folders_selected();
-
- let originalTab = mc.tabmail.currentTabInfo;
- let [newTab] = middle_click_on_folder(folderA);
- if (aBackground) {
- // Make sure we haven't switched to the new tab.
- assert_selected_tab(originalTab);
- // Now switch to the new tab and check
- switch_tab(newTab);
- }
- assert_folder_selected_and_displayed(folderA);
- close_tab(newTab);
-
- // XXX This is wrong, we shouldn't have anything selected. Since we don't
- // have a special state for nothing selected, we're giving this a pass for
- // now.
- assert_folder_selected_and_displayed(folderA);
-}
-
-/**
- * One-thing selected, middle-click on something else.
- */
-function _middle_click_folder_with_one_thing_selected_helper(aBackground) {
- select_click_folder(folderB);
- assert_folder_selected_and_displayed(folderB);
-
- let originalTab = mc.tabmail.currentTabInfo;
- let [newTab] = middle_click_on_folder(folderA);
- if (aBackground) {
- // Make sure we haven't switched to the new tab.
- assert_selected_tab(originalTab);
- // Now switch to the new tab and check
- switch_tab(newTab);
- }
- assert_folder_selected_and_displayed(folderA);
- close_tab(newTab);
-
- assert_folder_selected_and_displayed(folderB);
-}
-
-function _middle_click_folder_with_many_things_selected_helper(aBackground) {
- select_click_folder(folderB);
- select_shift_click_folder(folderC);
- assert_folders_selected_and_displayed(folderB, folderC);
-
- let originalTab = mc.tabmail.currentTabInfo;
- let [newTab] = middle_click_on_folder(folderA);
- if (aBackground) {
- // Make sure we haven't switched to the new tab.
- assert_selected_tab(originalTab);
- // Now switch to the new tab and check
- switch_tab(newTab);
- }
- assert_folder_selected_and_displayed(folderA);
- close_tab(newTab);
-
- // XXX Again, this is wrong. We're still giving it a pass because selecting
- // both folderB and folderC is currently the same as selecting folderB.
- assert_folder_selected_and_displayed(folderB);
-}
-
-/**
- * One thing selected, middle-click on that.
- */
-function _middle_click_folder_on_existing_single_selection_helper(aBackground) {
- select_click_folder(folderC);
- assert_folder_selected_and_displayed(folderC);
-
- let originalTab = mc.tabmail.currentTabInfo;
- let [newTab] = middle_click_on_folder(folderC);
- if (aBackground) {
- // Make sure we haven't switched to the new tab.
- assert_selected_tab(originalTab);
- // Now switch to the new tab and check
- switch_tab(newTab);
- }
- assert_folder_selected_and_displayed(folderC);
- close_tab(newTab);
-
- assert_folder_selected_and_displayed(folderC);
-}
-
-/**
- * Many things selected, middle-click somewhere in the selection.
- */
-function _middle_click_on_existing_multi_selection_helper(aBackground) {
- select_click_folder(folderA);
- select_shift_click_folder(folderC);
- assert_folders_selected_and_displayed(folderA, folderB, folderC);
-
- let originalTab = mc.tabmail.currentTabInfo;
- let [newTab] = middle_click_on_folder(folderB);
- if (aBackground) {
- // Make sure we haven't switched to the new tab.
- assert_selected_tab(originalTab);
- // Now switch to the new tab and check
- switch_tab(newTab);
- }
- assert_folder_selected_and_displayed(folderB);
- close_tab(newTab);
-
- // XXX Again, this is wrong. We're still giving it a pass because selecting
- // folderA through folderC is currently the same as selecting folderA.
- assert_folder_selected_and_displayed(folderA);
-}
-
-/**
- * Generate background and foreground tests for each middle click test.
- *
- * @param aTests an array of test names
- */
-var global = this;
-function _generate_background_foreground_tests(aTests) {
- for (let test of aTests) {
- let helperFunc = global["_" + test + "_helper"];
- global["test_" + test + "_background"] = function() {
- set_context_menu_background_tabs(true);
- helperFunc(true);
- reset_context_menu_background_tabs();
- };
- global["test_" + test + "_foreground"] = function() {
- set_context_menu_background_tabs(false);
- helperFunc(false);
- reset_context_menu_background_tabs();
- };
- }
-}
-
-_generate_background_foreground_tests([
- "middle_click_folder_with_nothing_selected",
- "middle_click_folder_with_one_thing_selected",
- "middle_click_folder_with_many_things_selected",
- "middle_click_folder_on_existing_single_selection",
-]);
deleted file mode 100644
--- a/mail/test/mozmill/folder-display/test-right-click-middle-click-messages.js
+++ /dev/null
@@ -1,543 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test the many horrors involving right-clicks, middle clicks, and selections.
- */
-
-"use strict";
-
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-
-var {
- add_sets_to_folders,
- assert_displayed,
- assert_message_not_in_view,
- assert_message_pane_focused,
- assert_messages_not_in_view,
- assert_nothing_selected,
- assert_selected,
- assert_selected_and_displayed,
- assert_selected_tab,
- assert_thread_tree_focused,
- be_in_folder,
- close_popup,
- close_tab,
- collapse_all_threads,
- create_folder,
- create_thread,
- delete_via_popup,
- expand_all_threads,
- focus_thread_tree,
- make_display_threaded,
- make_new_sets_in_folder,
- mc,
- middle_click_on_row,
- reset_context_menu_background_tabs,
- right_click_on_row,
- select_click_row,
- select_none,
- select_shift_click_row,
- set_context_menu_background_tabs,
- switch_tab,
- wait_for_message_display_completion,
- wait_for_popup_to_open,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var folder, threadedFolder;
-
-/**
- * The number of messages in the thread we use to test.
- */
-var NUM_MESSAGES_IN_THREAD = 6;
-
-function setupModule(module) {
- folder = create_folder("RightClickMiddleClickA");
- threadedFolder = create_folder("RightClickMiddleClickB");
- // we want exactly as many messages as we plan to delete, so that we can test
- // that the message window and tabs close when they run out of things to
- // to display.
- make_new_sets_in_folder(folder, [{ count: 20 }]);
- // Create a few messages and one thread (the order is important here, as it
- // determines where the thread is placed. We want it placed right at the
- // end.)
- make_new_sets_in_folder(threadedFolder, [{ count: 50 }]);
- let thread = create_thread(NUM_MESSAGES_IN_THREAD);
- add_sets_to_folders([threadedFolder], [thread]);
-}
-
-/**
- * Make sure that a right-click when there is nothing currently selected does
- * not cause us to display something, as well as correctly causing a transient
- * selection to occur.
- */
-function test_right_click_with_nothing_selected() {
- be_in_folder(folder);
-
- select_none();
- assert_nothing_selected();
-
- right_click_on_row(1);
- // Check that the popup opens.
- wait_for_popup_to_open(mc.e("mailContext"));
-
- assert_selected(1);
- assert_displayed();
-
- close_popup(mc, mc.eid("mailContext"));
- assert_nothing_selected();
-}
-
-/**
- * Test that clicking on the column header shows the column picker.
- */
-function test_right_click_column_header_shows_col_picker() {
- be_in_folder(folder);
-
- // The treecolpicker element itself doesn't have an id, so we have to walk
- // down from the parent to find it.
- // treadCols
- // |- hbox item 0
- // |- treecolpicker <-- item 1 this is the one we want
- let threadCols = mc.window.document.getElementById("threadCols");
- let treeColPicker = threadCols.querySelector("treecolpicker");
- let popup = treeColPicker.querySelector("[anonid=popup]");
-
- // Right click the subject column header
- // This should show the column picker popup.
- mc.rightClick(mc.eid("subjectCol"));
-
- // Check that the popup opens.
- wait_for_popup_to_open(popup);
- // Hide it again, we just wanted to know it was going to be shown.
- close_popup(mc, new elib.Elem(popup));
-}
-
-/**
- * One-thing selected, right-click on something else.
- */
-function test_right_click_with_one_thing_selected() {
- be_in_folder(folder);
-
- select_click_row(0);
- assert_selected_and_displayed(0);
-
- right_click_on_row(1);
- assert_selected(1);
- assert_displayed(0);
-
- close_popup(mc, mc.eid("mailContext"));
- assert_selected_and_displayed(0);
-}
-
-/**
- * Many things selected, right-click on something that is not in that selection.
- */
-function test_right_click_with_many_things_selected() {
- be_in_folder(folder);
-
- select_click_row(0);
- select_shift_click_row(5);
- assert_selected_and_displayed([0, 5]);
-
- right_click_on_row(6);
- assert_selected(6);
- assert_displayed([0, 5]);
-
- close_popup(mc, mc.eid("mailContext"));
- assert_selected_and_displayed([0, 5]);
-}
-
-/**
- * One thing selected, right-click on that.
- */
-function test_right_click_on_existing_single_selection() {
- be_in_folder(folder);
-
- select_click_row(3);
- assert_selected_and_displayed(3);
-
- right_click_on_row(3);
- assert_selected_and_displayed(3);
-
- close_popup(mc, mc.eid("mailContext"));
- assert_selected_and_displayed(3);
-}
-
-/**
- * Many things selected, right-click somewhere in the selection.
- */
-function test_right_click_on_existing_multi_selection() {
- be_in_folder(folder);
-
- select_click_row(3);
- select_shift_click_row(6);
- assert_selected_and_displayed([3, 6]);
-
- right_click_on_row(5);
- assert_selected_and_displayed([3, 6]);
-
- close_popup(mc, mc.eid("mailContext"));
- assert_selected_and_displayed([3, 6]);
-}
-
-/**
- * Middle clicking should open a message in a tab, but not affect our selection.
- */
-function _middle_click_with_nothing_selected_helper(aBackground) {
- be_in_folder(folder);
-
- select_none();
- assert_nothing_selected();
- let folderTab = mc.tabmail.currentTabInfo;
- // Focus the thread tree -- we're going to make sure it's focused when we
- // come back
- focus_thread_tree();
- let [tabMessage, curMessage] = middle_click_on_row(1);
- if (aBackground) {
- // Make sure we haven't switched to the new tab.
- assert_selected_tab(folderTab);
- // Now switch to the new tab and check
- switch_tab(tabMessage);
- } else {
- wait_for_message_display_completion();
- }
-
- assert_selected_and_displayed(curMessage);
- assert_message_pane_focused();
- close_tab(tabMessage);
-
- assert_nothing_selected();
- assert_thread_tree_focused();
-}
-
-/**
- * One-thing selected, middle-click on something else.
- */
-function _middle_click_with_one_thing_selected_helper(aBackground) {
- be_in_folder(folder);
-
- select_click_row(0);
- assert_selected_and_displayed(0);
-
- let folderTab = mc.tabmail.currentTabInfo;
- let [tabMessage, curMessage] = middle_click_on_row(1);
- if (aBackground) {
- // Make sure we haven't switched to the new tab.
- assert_selected_tab(folderTab);
- // Now switch to the new tab and check
- switch_tab(tabMessage);
- } else {
- wait_for_message_display_completion();
- }
-
- assert_selected_and_displayed(curMessage);
- assert_message_pane_focused();
- close_tab(tabMessage);
-
- assert_selected_and_displayed(0);
- assert_thread_tree_focused();
-}
-
-/**
- * Many things selected, middle-click on something that is not in that
- * selection.
- */
-function _middle_click_with_many_things_selected_helper(aBackground) {
- be_in_folder(folder);
-
- select_click_row(0);
- select_shift_click_row(5);
- assert_selected_and_displayed([0, 5]);
-
- let folderTab = mc.tabmail.currentTabInfo;
- let [tabMessage, curMessage] = middle_click_on_row(1);
- if (aBackground) {
- // Make sure we haven't switched to the new tab.
- assert_selected_tab(folderTab);
- // Now switch to the new tab and check
- switch_tab(tabMessage);
- } else {
- wait_for_message_display_completion();
- }
-
- assert_selected_and_displayed(curMessage);
- assert_message_pane_focused();
- close_tab(tabMessage);
-
- assert_selected_and_displayed([0, 5]);
- assert_thread_tree_focused();
-}
-
-/**
- * One thing selected, middle-click on that.
- */
-function _middle_click_on_existing_single_selection_helper(aBackground) {
- be_in_folder(folder);
-
- select_click_row(3);
- assert_selected_and_displayed(3);
-
- let folderTab = mc.tabmail.currentTabInfo;
- let [tabMessage, curMessage] = middle_click_on_row(3);
- if (aBackground) {
- // Make sure we haven't switched to the new tab.
- assert_selected_tab(folderTab);
- // Now switch to the new tab and check
- switch_tab(tabMessage);
- } else {
- wait_for_message_display_completion();
- }
-
- assert_selected_and_displayed(curMessage);
- assert_message_pane_focused();
- close_tab(tabMessage);
-
- assert_selected_and_displayed(3);
- assert_thread_tree_focused();
-}
-
-/**
- * Many things selected, middle-click somewhere in the selection.
- */
-function _middle_click_on_existing_multi_selection_helper(aBackground) {
- be_in_folder(folder);
-
- select_click_row(3);
- select_shift_click_row(6);
- assert_selected_and_displayed([3, 6]);
-
- let folderTab = mc.tabmail.currentTabInfo;
- let [tabMessage, curMessage] = middle_click_on_row(5);
- if (aBackground) {
- // Make sure we haven't switched to the new tab.
- assert_selected_tab(folderTab);
- // Now switch to the new tab and check
- switch_tab(tabMessage);
- } else {
- wait_for_message_display_completion();
- }
-
- assert_selected_and_displayed(curMessage);
- assert_message_pane_focused();
- close_tab(tabMessage);
-
- assert_selected_and_displayed([3, 6]);
- assert_thread_tree_focused();
-}
-
-/**
- * Middle-click on the root of a collapsed thread, making sure that we don't
- * jump around in the thread tree.
- */
-function _middle_click_on_collapsed_thread_root_helper(aBackground) {
- be_in_folder(threadedFolder);
- make_display_threaded();
- collapse_all_threads();
-
- let folderTab = mc.tabmail.currentTabInfo;
-
- let tree = mc.threadTree;
- // Scroll to the top, then to the bottom
- tree.ensureRowIsVisible(0);
- tree.scrollByLines(mc.folderDisplay.view.dbView.rowCount);
- // Note the first visible row
- let preFirstRow = tree.getFirstVisibleRow();
-
- // Since reflowing a tree (eg when switching tabs) ensures that the current
- // index is brought into view, we need to set the current index so that we
- // don't scroll because of it. So click on the first visible row.
- select_click_row(preFirstRow);
-
- // Middle-click on the root of the collapsed thread, which is also the last
- // row
- let [tabMessage] = middle_click_on_row(
- mc.folderDisplay.view.dbView.rowCount - 1
- );
-
- if (!aBackground) {
- wait_for_message_display_completion();
- // Switch back to the folder tab
- switch_tab(folderTab);
- }
-
- // Make sure the first visible row is still the same
- if (tree.getFirstVisibleRow() != preFirstRow) {
- throw new Error(
- "The first visible row should have been " +
- preFirstRow +
- ", but is actually " +
- tree.getFirstVisibleRow() +
- "."
- );
- }
-
- close_tab(tabMessage);
-}
-
-/**
- * Middle-click on the root of an expanded thread, making sure that we don't
- * jump around in the thread tree.
- */
-function _middle_click_on_expanded_thread_root_helper(aBackground) {
- be_in_folder(threadedFolder);
- make_display_threaded();
- expand_all_threads();
-
- let folderTab = mc.tabmail.currentTabInfo;
-
- let tree = mc.threadTree;
- // Scroll to the top, then to near (but not exactly) the bottom
- tree.ensureRowIsVisible(0);
- tree.scrollToRow(
- mc.folderDisplay.view.dbView.rowCount -
- tree.getPageLength() -
- NUM_MESSAGES_IN_THREAD / 2
- );
- // Note the first visible row
- let preFirstRow = tree.getFirstVisibleRow();
-
- // Since reflowing a tree (eg when switching tabs) ensures that the current
- // index is brought into view, we need to set the current index so that we
- // don't scroll because of it. So click on the first visible row.
- select_click_row(preFirstRow);
-
- // Middle-click on the root of the expanded thread, which is the row with
- // index (number of rows - number of messages in thread).
- let [tabMessage] = middle_click_on_row(
- mc.folderDisplay.view.dbView.rowCount - NUM_MESSAGES_IN_THREAD
- );
-
- if (!aBackground) {
- wait_for_message_display_completion();
- // Switch back to the folder tab
- switch_tab(folderTab);
- }
-
- // Make sure the first visible row is still the same
- if (tree.getFirstVisibleRow() != preFirstRow) {
- throw new Error(
- "The first visible row should have been " +
- preFirstRow +
- ", but is actually " +
- tree.getFirstVisibleRow() +
- "."
- );
- }
-
- close_tab(tabMessage);
-}
-
-/**
- * Generate background and foreground tests for each middle click test.
- *
- * @param aTests an array of test names
- */
-var global = this;
-function _generate_background_foreground_tests(aTests) {
- for (let test of aTests) {
- let helperFunc = global["_" + test + "_helper"];
- global["test_" + test + "_background"] = function() {
- set_context_menu_background_tabs(true);
- helperFunc(true);
- reset_context_menu_background_tabs();
- };
- global["test_" + test + "_foreground"] = function() {
- set_context_menu_background_tabs(false);
- helperFunc(false);
- reset_context_menu_background_tabs();
- };
- }
-}
-
-_generate_background_foreground_tests([
- "middle_click_with_nothing_selected",
- "middle_click_with_one_thing_selected",
- "middle_click_with_many_things_selected",
- "middle_click_on_existing_single_selection",
- "middle_click_on_existing_multi_selection",
- "middle_click_on_collapsed_thread_root",
- "middle_click_on_expanded_thread_root",
-]);
-
-/**
- * Right-click on something and delete it, having no selection previously.
- */
-function test_right_click_deletion_nothing_selected() {
- be_in_folder(folder);
-
- select_none();
- assert_selected_and_displayed();
-
- let delMessage = right_click_on_row(3);
- delete_via_popup();
- // eh, might as well make sure the deletion worked while we are here
- assert_message_not_in_view(delMessage);
-
- assert_selected_and_displayed();
-}
-
-/**
- * We want to make sure that the selection post-delete still includes the same
- * message (and that it is displayed). In order for this to be interesting,
- * we want to make sure that we right-click delete a message above the selected
- * message so there is a shift in row numbering.
- */
-function test_right_click_deletion_one_other_thing_selected() {
- be_in_folder(folder);
-
- let curMessage = select_click_row(5);
-
- let delMessage = right_click_on_row(3);
- delete_via_popup();
- assert_message_not_in_view(delMessage);
-
- assert_selected_and_displayed(curMessage);
-}
-
-function test_right_click_deletion_many_other_things_selected() {
- be_in_folder(folder);
-
- select_click_row(4);
- let messages = select_shift_click_row(6);
-
- let delMessage = right_click_on_row(2);
- delete_via_popup();
- assert_message_not_in_view(delMessage);
-
- assert_selected_and_displayed(messages);
-}
-
-function test_right_click_deletion_of_one_selected_thing() {
- be_in_folder(folder);
-
- let curMessage = select_click_row(2);
-
- right_click_on_row(2);
- delete_via_popup();
- assert_message_not_in_view(curMessage);
-
- if (!mc.folderDisplay.selectedCount) {
- throw new Error("We should have tried to select something!");
- }
-}
-
-function test_right_click_deletion_of_many_selected_things() {
- be_in_folder(folder);
-
- select_click_row(2);
- let messages = select_shift_click_row(4);
-
- right_click_on_row(3);
- delete_via_popup();
- assert_messages_not_in_view(messages);
-
- if (!mc.folderDisplay.selectedCount) {
- throw new Error("We should have tried to select something!");
- }
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-display/test-savedsearch-reload-after-compact.js
+++ /dev/null
@@ -1,75 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Test reload of saved searches over local folders after compaction
- * of local folders.
- */
-
-"use strict";
-
-var {
- be_in_folder,
- create_folder,
- create_virtual_folder,
- inboxFolder,
- make_new_sets_in_folder,
- mc,
- press_delete,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-/**
- * Add some messages to a folder, delete the first one, and create a saved
- * search over the inbox and the folder. Then, compact folders.
- */
-function test_setup_virtual_folder_and_compact() {
- let otherFolder = create_folder("otherFolder");
- make_new_sets_in_folder(otherFolder, [{ count: 2 }]);
-
- /**
- * We delete the first message in the local folder, so compaction of the
- * folder will invalidate the key of the second message in the folder. Then,
- * we select the second message and issue the compact. This causes saving the
- * selection on the compaction notification to fail. We test the saved search
- * view still gets rebuilt, such that there is a valid msg hdr at row 0.
- */
- be_in_folder(otherFolder);
- select_click_row(0);
- press_delete();
-
- let folderVirtual = create_virtual_folder(
- [inboxFolder, otherFolder],
- {},
- true,
- "SavedSearch"
- );
-
- be_in_folder(folderVirtual);
- select_click_row(0);
- let urlListener = {
- compactDone: false,
-
- OnStartRunningUrl(aUrl) {},
- OnStopRunningUrl(aUrl, aExitCode) {
- this.compactDone = true;
- },
- };
- if (otherFolder.msgStore.supportsCompaction) {
- otherFolder.compactAll(urlListener, null, false);
-
- mc.waitFor(
- () => urlListener.compactDone,
- "Timeout waiting for compact to complete",
- 10000,
- 100
- );
- }
- // Let the event queue clear.
- mc.sleep(0);
- // Check view is still valid
- mc.dbView.getMsgHdrAt(0);
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-display/test-selection.js
+++ /dev/null
@@ -1,198 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-var {
- assert_nothing_selected,
- assert_selected_and_displayed,
- assert_visible,
- be_in_folder,
- close_tab,
- create_folder,
- delete_via_popup,
- enter_folder,
- make_display_grouped,
- make_display_threaded,
- make_display_unthreaded,
- make_new_sets_in_folder,
- make_new_sets_in_folders,
- mc,
- open_folder_in_new_tab,
- press_delete,
- right_click_on_row,
- select_click_row,
- select_column_click_row,
- select_control_click_row,
- select_none,
- select_shift_click_row,
- switch_tab,
- wait_for_blank_content_pane,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-// let us have 2 folders
-var folder = null,
- folder2 = null;
-
-var setupModule = function(module) {
- folder = create_folder("SelectionA");
- folder2 = create_folder("SelectionB");
- make_new_sets_in_folders([folder, folder2], [{ count: 50 }]);
-};
-
-// https://bugzilla.mozilla.org/show_bug.cgi?id=474701#c80
-function test_selection_on_entry() {
- enter_folder(folder);
- assert_nothing_selected();
-}
-
-function test_selection_extension() {
- be_in_folder(folder);
-
- // https://bugzilla.mozilla.org/show_bug.cgi?id=474701#c79 (was good)
- select_click_row(1);
- select_control_click_row(2);
- press_delete();
- assert_selected_and_displayed(1);
- // https://bugzilla.mozilla.org/show_bug.cgi?id=474701#c79 (was bad)
- select_click_row(2);
- select_control_click_row(1);
- press_delete();
- assert_selected_and_displayed(1);
-
- // https://bugzilla.mozilla.org/show_bug.cgi?id=474701#c87 first bit
- press_delete();
- assert_selected_and_displayed(1);
-}
-
-function test_selection_select_column() {
- be_in_folder(folder);
- mc.e("selectCol").removeAttribute("hidden");
- select_none();
- select_column_click_row(0);
- assert_selected_and_displayed(0);
- select_column_click_row(0);
- assert_nothing_selected();
- select_column_click_row(2);
- select_column_click_row(3);
- select_column_click_row(4);
- // This only takes a range.
- assert_selected_and_displayed([2, 4]); // ensures multi-message summary
- select_column_click_row(2);
- assert_selected_and_displayed([3, 4]); // ensures multi-message summary
- select_column_click_row(3);
- assert_selected_and_displayed(4);
- select_column_click_row(4);
- assert_nothing_selected();
-}
-
-function test_selection_select_column_deselection() {
- be_in_folder(folder);
- select_none();
- select_column_click_row(3);
- select_column_click_row(3);
- assert_nothing_selected();
- right_click_on_row(7);
- delete_via_popup();
- assert_nothing_selected();
- mc.e("selectCol").setAttribute("hidden", true);
-}
-
-// https://bugzilla.mozilla.org/show_bug.cgi?id=474701#c87 last bit
-function test_selection_last_message_deleted() {
- be_in_folder(folder);
- select_click_row(-1);
- press_delete();
- assert_selected_and_displayed(-1);
-}
-test_selection_last_message_deleted.EXCLUDED_PLATFORMS = ["darwin", "linux"];
-
-function test_selection_persists_through_threading_changes() {
- be_in_folder(folder);
-
- make_display_unthreaded();
- let message = select_click_row(3);
- make_display_threaded();
- assert_selected_and_displayed(message);
- make_display_grouped();
- assert_selected_and_displayed(message);
-}
-
-// https://bugzilla.mozilla.org/show_bug.cgi?id=474701#c82 2nd half
-function test_no_selection_persists_through_threading_changes() {
- be_in_folder(folder);
-
- make_display_unthreaded();
- select_none();
- make_display_threaded();
- assert_nothing_selected();
- make_display_grouped();
- assert_nothing_selected();
- make_display_unthreaded();
-}
-
-function test_selection_persists_through_folder_tab_changes() {
- let tab1 = be_in_folder(folder);
-
- select_click_row(2);
-
- let tab2 = open_folder_in_new_tab(folder2);
- wait_for_blank_content_pane();
- assert_nothing_selected();
-
- switch_tab(tab1);
- assert_selected_and_displayed(2);
-
- switch_tab(tab2);
- assert_nothing_selected();
- select_click_row(3);
-
- switch_tab(tab1);
- assert_selected_and_displayed(2);
- select_shift_click_row(4); // 2-4 selected
- assert_selected_and_displayed([2, 4]); // ensures multi-message summary
-
- switch_tab(tab2);
- assert_selected_and_displayed(3);
-
- close_tab(tab2);
- assert_selected_and_displayed([2, 4]);
-}
-
-// https://bugzilla.mozilla.org/show_bug.cgi?id=474701#c87
-/**
- * Verify that we scroll to new messages when we enter a folder.
- */
-function test_enter_scroll_to_new() {
- // be in the folder
- be_in_folder(folder);
- // make sure the sort is ascending...
- mc.folderDisplay.view.sortAscending();
- // leave the folder so that the messages get marked as read
- enter_folder(folder.rootFolder);
- // add a new message, and make sure it is new
- make_new_sets_in_folder(folder, [{ count: 1 }]);
- // enter the folder
- enter_folder(folder);
- // make sure it (which must be the last row) is visible
- assert_visible(-1);
-}
-test_enter_scroll_to_new.EXCLUDED_PLATFORMS = ["darwin", "linux"];
-
-/**
- * Test that the last selected message persists through folder changes.
- */
-function test_selection_persists_through_folder_changes() {
- // be in the folder
- be_in_folder(folder);
- // select a message
- select_click_row(3);
- // leave and re-enter the folder
- enter_folder(folder.rootFolder);
- enter_folder(folder);
- // make sure it is selected and displayed
- assert_selected_and_displayed(3);
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-display/test-summarization.js
+++ /dev/null
@@ -1,406 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Test that summarization happens at the right time, that it clears itself at
- * the right time, that it waits for selection stability when recently
- * summarized, and that summarization does not break under tabbing.
- *
- * Because most of the legwork is done automatically by
- * test-folder-display-helpers, the more basic tests may look like general
- * selection / tabbing tests, but are intended to specifically exercise the
- * summarization logic and edge cases. (Although general selection tests and
- * tab tests may do the same thing too...)
- *
- * Things we don't test but should:
- * - The difference between thread summary and multi-message summary.
- */
-
-"use strict";
-
-var { ensure_card_exists, ensure_no_card_exists } = ChromeUtils.import(
- "resource://testing-common/mozmill/AddressBookHelpers.jsm"
-);
-var {
- add_sets_to_folders,
- assert_collapsed,
- assert_expanded,
- assert_messages_summarized,
- assert_nothing_selected,
- assert_selected,
- assert_selected_and_displayed,
- assert_summary_contains_N_elts,
- be_in_folder,
- close_tab,
- collapse_all_threads,
- create_folder,
- create_thread,
- create_virtual_folder,
- make_display_threaded,
- make_new_sets_in_folders,
- mc,
- open_folder_in_new_tab,
- open_selected_message_in_new_tab,
- plan_to_wait_for_folder_events,
- select_click_row,
- select_control_click_row,
- select_none,
- select_shift_click_row,
- switch_tab,
- toggle_thread_row,
- wait_for_blank_content_pane,
- wait_for_folder_events,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-var folder;
-var thread1, thread2, msg1, msg2;
-
-var setupModule = function(module) {
- folder = create_folder("SummarizationA");
- thread1 = create_thread(10);
- msg1 = create_thread(1);
- thread2 = create_thread(10);
- msg2 = create_thread(1);
- add_sets_to_folders([folder], [thread1, msg1, thread2, msg2]);
-};
-
-function test_basic_summarization() {
- be_in_folder(folder);
-
- // - make sure we get a summary
- select_click_row(0);
- select_shift_click_row(5);
- // this will verify a multi-message display is happening
- assert_selected_and_displayed([0, 5]);
-}
-
-function test_summarization_goes_away() {
- select_none();
- assert_nothing_selected();
-}
-
-/**
- * Verify that we update summarization when switching amongst tabs.
- */
-function test_folder_tabs_update_correctly() {
- // tab with summary
- let tabA = be_in_folder(folder);
- select_click_row(0);
- select_control_click_row(2);
- assert_selected_and_displayed(0, 2);
-
- // tab with nothing
- let tabB = open_folder_in_new_tab(folder);
- wait_for_blank_content_pane();
- assert_nothing_selected();
-
- // correct changes, none <=> summary
- switch_tab(tabA);
- assert_selected_and_displayed(0, 2);
- switch_tab(tabB);
- assert_nothing_selected();
-
- // correct changes, one <=> summary
- select_click_row(0);
- assert_selected_and_displayed(0);
- switch_tab(tabA);
- assert_selected_and_displayed(0, 2);
- switch_tab(tabB);
- assert_selected_and_displayed(0);
-
- // correct changes, summary <=> summary
- select_shift_click_row(3);
- assert_selected_and_displayed([0, 3]);
- switch_tab(tabA);
- assert_selected_and_displayed(0, 2);
- switch_tab(tabB);
- assert_selected_and_displayed([0, 3]);
-
- // closing tab returns state correctly...
- close_tab(tabB);
- assert_selected_and_displayed(0, 2);
-}
-
-function test_message_tabs_update_correctly() {
- let tabFolder = be_in_folder(folder);
- let message = select_click_row(0);
- assert_selected_and_displayed(0);
-
- let tabMessage = open_selected_message_in_new_tab();
- assert_selected_and_displayed(message);
-
- switch_tab(tabFolder);
- select_shift_click_row(2);
- assert_selected_and_displayed([0, 2]);
-
- switch_tab(tabMessage);
- assert_selected_and_displayed(message);
-
- switch_tab(tabFolder);
- assert_selected_and_displayed([0, 2]);
-
- close_tab(tabMessage);
-}
-
-/**
- * Test the stabilization logic by making the stabilization interval absurd and
- * then manually clearing things up.
- */
-function test_selection_stabilization_logic() {
- // make sure all summarization has run to completion.
- mc.sleep(0);
- // make it inconceivable that the timeout happens.
- mc.window.MessageDisplayWidget.prototype.SUMMARIZATION_SELECTION_STABILITY_INTERVAL_MS = 10000;
- // does not summarize anything, does not affect timer
- select_click_row(0);
- // does summarize things. timer will be tick tick ticking!
- select_shift_click_row(1);
- // verify that things were summarized...
- assert_selected_and_displayed([0, 1]);
- // save the set of messages so we can verify the summary sticks to this.
- let messages = mc.folderDisplay.selectedMessages;
-
- // make sure the
-
- // this will not summarize!
- select_shift_click_row(2, mc, true);
- // verify that our summary is still just 0 and 1.
- assert_messages_summarized(mc, messages);
-
- // - put it back, the way it was
- // oh put it back the way it was
- // ...
- // That's right folks, a 'Lil Abner reference.
- // ...
- // Culture!
- // ...
- // I'm already embarrassed I wrote that.
- mc.window.MessageDisplayWidget.prototype.SUMMARIZATION_SELECTION_STABILITY_INTERVAL_MS = 0;
- // (we did that because the stability logic is going to schedule another guard
- // timer when we manually trigger it, and we want that to clear immediately.)
-
- // - pretend the timer fired.
- // we need to de-schedule the timer, but do not need to clear the variable
- // because it will just get overwritten anyways
- mc.window.clearTimeout(mc.messageDisplay._summaryStabilityTimeout);
- mc.messageDisplay._showSummary(true);
-
- // - the summary should now be up-to-date
- assert_selected_and_displayed([0, 2]);
-}
-
-function test_summarization_thread_detection() {
- select_none();
- assert_nothing_selected();
- make_display_threaded();
- select_click_row(0);
- select_shift_click_row(9);
- let messages = mc.folderDisplay.selectedMessages;
- toggle_thread_row(0);
- assert_messages_summarized(mc, messages);
- // count the number of messages represented
- assert_summary_contains_N_elts("#message_list > li", 10);
- select_shift_click_row(1);
- // this should have shifted to the multi-message view
- assert_summary_contains_N_elts(".item_header > .date", 0);
- assert_summary_contains_N_elts(".item_header > .subject", 2);
- select_none();
- assert_nothing_selected();
- select_click_row(1); // select a single message
- select_shift_click_row(2); // add a thread
- assert_summary_contains_N_elts(".item_header > .date", 0);
- assert_summary_contains_N_elts(".item_header > .subject", 2);
-}
-
-/**
- * If you are looking at a message that becomes part of a thread because of the
- * arrival of a new message, expand the thread so you do not have the message
- * turn into a summary beneath your feet.
- *
- * There are really two cases here:
- * - The thread gets moved because its sorted position changes.
- * - The thread does not move.
- */
-function test_new_thread_that_was_not_summarized_expands() {
- be_in_folder(folder);
- make_display_threaded();
-
- // - create the base messages
- let [willMoveMsg, willNotMoveMsg] = make_new_sets_in_folders(
- [folder],
- [{ count: 1 }, { count: 1 }]
- );
-
- // - do the non-move case
- // XXX actually, this still gets treated as a move. I don't know why...
- // select it
- select_click_row(willNotMoveMsg);
- assert_selected_and_displayed(willNotMoveMsg);
-
- // give it a friend...
- make_new_sets_in_folders([folder], [{ count: 1, inReplyTo: willNotMoveMsg }]);
- assert_expanded(willNotMoveMsg);
- assert_selected_and_displayed(willNotMoveMsg);
-
- // - do the move case
- select_click_row(willMoveMsg);
- assert_selected_and_displayed(willMoveMsg);
-
- // give it a friend...
- make_new_sets_in_folders([folder], [{ count: 1, inReplyTo: willMoveMsg }]);
- assert_expanded(willMoveMsg);
- assert_selected_and_displayed(willMoveMsg);
-}
-
-/**
- * Selecting an existing (and collapsed) thread, then add a message and make
- * sure the summary updates.
- */
-function test_summary_updates_when_new_message_added_to_collapsed_thread() {
- be_in_folder(folder);
- make_display_threaded();
- collapse_all_threads();
-
- // - select the thread root, thereby summarizing it
- let thread1Root = select_click_row(thread1); // this just uses the root msg
- assert_collapsed(thread1Root);
- // just the thread root should be selected
- assert_selected(thread1Root);
- // but the whole thread should be summarized
- assert_messages_summarized(mc, thread1);
-
- // - add a new message, make sure it's in the summary now.
- let [thread1Extra] = make_new_sets_in_folders(
- [folder],
- [{ count: 1, inReplyTo: thread1 }]
- );
- let thread1All = thread1.union(thread1Extra);
- assert_selected(thread1Root);
- assert_messages_summarized(mc, thread1All);
-}
-
-function test_summary_when_multiple_identities() {
- // First half of the test, makes sure messageDisplay.js understands there's
- // only one thread
- let folder1 = create_folder("Search1");
- be_in_folder(folder1);
- let thread1 = create_thread(1);
- add_sets_to_folders([folder1], [thread1]);
-
- let folder2 = create_folder("Search2");
- be_in_folder(folder2);
- make_new_sets_in_folders([folder2], [{ count: 1, inReplyTo: thread1 }]);
-
- let folderVirtual = create_virtual_folder(
- [folder1, folder2],
- {},
- true,
- "SearchBoth"
- );
-
- // Do the needed tricks
- be_in_folder(folder1);
- select_click_row(0);
- plan_to_wait_for_folder_events(
- "DeleteOrMoveMsgCompleted",
- "DeleteOrMoveMsgFailed"
- );
- mc.window.MsgMoveMessage(folder2);
- wait_for_folder_events();
-
- be_in_folder(folder2);
- select_click_row(1);
- plan_to_wait_for_folder_events(
- "DeleteOrMoveMsgCompleted",
- "DeleteOrMoveMsgFailed"
- );
- mc.window.MsgMoveMessage(folder1);
- wait_for_folder_events();
-
- be_in_folder(folderVirtual);
- make_display_threaded();
- collapse_all_threads();
-
- // Assertions
- select_click_row(0);
- assert_messages_summarized(mc, mc.folderDisplay.selectedMessages);
- // Thread summary shows a date, while multimessage summary shows a subject.
- assert_summary_contains_N_elts(".item_header > .subject", 0);
- assert_summary_contains_N_elts(".item_header > .date", 2);
-
- // Second half of the test, makes sure MultiMessageSummary groups messages
- // according to their view thread id
- thread1 = create_thread(1);
- add_sets_to_folders([folder1], [thread1]);
- be_in_folder(folderVirtual);
- select_shift_click_row(1);
-
- assert_summary_contains_N_elts(".item_header > .subject", 2);
-}
-
-function extract_first_address(thread) {
- let addresses = MailServices.headerParser.parseEncodedHeader(
- thread1.getMsgHdr(0).mime2DecodedAuthor
- );
- return addresses[0];
-}
-
-function check_address_name(name) {
- let htmlframe = mc.e("multimessage");
- let match = htmlframe.contentDocument.querySelector(".author");
- if (match.textContent != name) {
- throw new Error(
- "Expected to find sender named '" +
- name +
- "', found '" +
- match.textContent +
- "'"
- );
- }
-}
-
-function test_display_name_no_abook() {
- be_in_folder(folder);
-
- let address = extract_first_address(thread1);
- ensure_no_card_exists(address.email);
-
- collapse_all_threads();
- select_click_row(thread1);
-
- // No address book entry, we display name and e-mail address.
- check_address_name(address.name + " <" + address.email + ">");
-}
-
-function test_display_name_abook() {
- be_in_folder(folder);
-
- let address = extract_first_address(thread1);
- ensure_card_exists(address.email, "My Friend", true);
-
- collapse_all_threads();
- select_click_row(thread1);
-
- check_address_name("My Friend");
-}
-
-function test_display_name_abook_no_pdn() {
- be_in_folder(folder);
-
- let address = extract_first_address(thread1);
- ensure_card_exists(address.email, "My Friend", false);
-
- collapse_all_threads();
- select_click_row(thread1);
-
- // With address book entry but display name not preferred, we display name and
- // e-mail address.
- check_address_name(address.name + " <" + address.email + ">");
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-display/test-tabs-simple.js
+++ /dev/null
@@ -1,188 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test that opening new folder and message tabs has the expected result and
- * that closing them doesn't break anything. sid0 added checks for focus
- * transitions at one point; I (asuth) am changing our test infrastructure to
- * cause more realistic focus changes so those changes now look sillier
- * because in many cases we are explicitly setting focus back after the thread
- * tree gains focus.
- */
-
-"use strict";
-
-var {
- assert_folder_tree_focused,
- assert_message_pane_focused,
- assert_messages_in_view,
- assert_nothing_selected,
- assert_selected_and_displayed,
- assert_thread_tree_focused,
- be_in_folder,
- close_tab,
- create_folder,
- focus_folder_tree,
- focus_message_pane,
- focus_thread_tree,
- make_new_sets_in_folder,
- mc,
- open_folder_in_new_tab,
- open_selected_message_in_new_tab,
- select_click_row,
- switch_tab,
- wait_for_blank_content_pane,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var folderA, folderB, setA, setB;
-
-function setupModule(module) {
- folderA = create_folder("TabsSimpleA");
- folderB = create_folder("TabsSimpleB");
-
- // We will verify we are seeing the right folder by checking that it has the
- // right messages in it.
- [setA] = make_new_sets_in_folder(folderA, [{}]);
- [setB] = make_new_sets_in_folder(folderB, [{}]);
-}
-
-/** The tabs in our test. */
-var tabFolderA, tabFolderB, tabMessageA, tabMessageB;
-/** The message that we selected for tab display, to check it worked right. */
-var messageA, messageB;
-
-/**
- * Make sure the default tab works right.
- */
-function test_open_folder_a() {
- tabFolderA = be_in_folder(folderA);
- assert_messages_in_view(setA);
- assert_nothing_selected();
- // Focus the folder tree here
- focus_folder_tree();
-}
-
-/**
- * Open tab b, make sure it works right.
- */
-function test_open_folder_b_in_tab() {
- tabFolderB = open_folder_in_new_tab(folderB);
- wait_for_blank_content_pane();
- assert_messages_in_view(setB);
- assert_nothing_selected();
- focus_thread_tree();
-}
-
-/**
- * Go back to tab/folder A and make sure we change correctly.
- */
-function test_switch_to_tab_folder_a() {
- switch_tab(tabFolderA);
- assert_messages_in_view(setA);
- assert_nothing_selected();
- assert_folder_tree_focused();
-}
-
-/**
- * Select a message in folder A and open it in a new window, making sure that
- * the displayed message is the right one.
- */
-function test_open_message_a_in_tab() {
- // (this focuses the thread tree for tabFolderA...)
- messageA = select_click_row(0);
- // (...refocus the folder tree for our sticky check below)
- focus_folder_tree();
- tabMessageA = open_selected_message_in_new_tab();
- assert_selected_and_displayed(messageA);
- assert_message_pane_focused();
-}
-
-/**
- * Go back to tab/folder B and make sure we change correctly.
- */
-function test_switch_to_tab_folder_b() {
- switch_tab(tabFolderB);
- assert_messages_in_view(setB);
- assert_nothing_selected();
- assert_thread_tree_focused();
-}
-
-/**
- * Select a message in folder B and open it in a new window, making sure that
- * the displayed message is the right one.
- */
-function test_open_message_b_in_tab() {
- messageB = select_click_row(0);
- // Let's focus the message pane now
- focus_message_pane();
- tabMessageB = open_selected_message_in_new_tab();
- assert_selected_and_displayed(messageB);
- assert_message_pane_focused();
-}
-
-/**
- * Switch to message tab A.
- */
-function test_switch_to_message_a() {
- switch_tab(tabMessageA);
- assert_selected_and_displayed(messageA);
- assert_message_pane_focused();
-}
-
-/**
- * Close message tab A (when it's in the foreground).
- */
-function test_close_message_a() {
- close_tab();
- // our current tab is now undefined for the purposes of this test.
-}
-
-/**
- * Make sure all the other tabs are still happy.
- */
-function test_tabs_are_still_happy() {
- switch_tab(tabFolderB);
- assert_messages_in_view(setB);
- assert_selected_and_displayed(messageB);
- assert_message_pane_focused();
-
- switch_tab(tabMessageB);
- assert_selected_and_displayed(messageB);
- assert_message_pane_focused();
-
- switch_tab(tabFolderA);
- assert_messages_in_view(setA);
- assert_selected_and_displayed(messageA);
- // focus restoration uses setTimeout(0) and so we need to give it a chance
- mc.sleep(0);
- assert_folder_tree_focused();
-}
-
-/**
- * Close message tab B (when it's in the background).
- */
-function test_close_message_b() {
- close_tab(tabMessageB);
- // we should still be on folder A
- assert_messages_in_view(setA);
- assert_selected_and_displayed(messageA);
- assert_folder_tree_focused();
-}
-
-/**
- * Switch to tab B, close it, make sure we end up on tab A.
- */
-function test_close_folder_b() {
- switch_tab(tabFolderB);
- assert_messages_in_view(setB);
- assert_selected_and_displayed(messageB);
- assert_message_pane_focused();
-
- close_tab();
- assert_messages_in_view(setA);
- assert_selected_and_displayed(messageA);
- assert_folder_tree_focused();
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-display/test-virtual-folder-commands.js
+++ /dev/null
@@ -1,78 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test that commands on virtual folders work properly.
- */
-
-"use strict";
-
-var {
- assert_true,
- be_in_folder,
- expand_all_threads,
- make_display_threaded,
- make_folder_with_sets,
- make_virtual_folder,
- mc,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var msgsPerThread = 5;
-var singleVirtFolder;
-var multiVirtFolder;
-
-function setupModule(module) {
- let [folderOne] = make_folder_with_sets([{ msgsPerThread }]);
- let [folderTwo] = make_folder_with_sets([{ msgsPerThread }]);
-
- singleVirtFolder = make_virtual_folder([folderOne], {});
- multiVirtFolder = make_virtual_folder([folderOne, folderTwo], {});
-}
-
-function test_single_folder_select_thread() {
- be_in_folder(singleVirtFolder);
- make_display_threaded();
- expand_all_threads();
-
- // Try selecting the thread from the root message.
- select_click_row(0);
- mc.keypress(null, "a", { accelKey: true, shiftKey: true });
- assert_true(
- mc.folderDisplay.selectedCount == msgsPerThread,
- "Didn't select all messages in the thread!"
- );
-
- // Now try selecting the thread from a non-root message.
- select_click_row(1);
- mc.keypress(null, "a", { accelKey: true, shiftKey: true });
- assert_true(
- mc.folderDisplay.selectedCount == msgsPerThread,
- "Didn't select all messages in the thread!"
- );
-}
-
-function test_cross_folder_select_thread() {
- be_in_folder(multiVirtFolder);
- make_display_threaded();
- expand_all_threads();
-
- // Try selecting the thread from the root message.
- select_click_row(0);
- mc.keypress(null, "a", { accelKey: true, shiftKey: true });
- assert_true(
- mc.folderDisplay.selectedCount == msgsPerThread,
- "Didn't select all messages in the thread!"
- );
-
- // Now try selecting the thread from a non-root message.
- select_click_row(1);
- mc.keypress(null, "a", { accelKey: true, shiftKey: true });
- assert_true(
- mc.folderDisplay.selectedCount == msgsPerThread,
- "Didn't select all messages in the thread!"
- );
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-display/test-watch-ignore-thread.js
+++ /dev/null
@@ -1,124 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test that "watch thread" and "ignore thread" works correctly.
- */
-
-"use strict";
-
-var {
- add_sets_to_folders,
- assert_not_shown,
- assert_selected_and_displayed,
- assert_visible,
- be_in_folder,
- create_folder,
- create_thread,
- expand_all_threads,
- inboxFolder,
- make_display_threaded,
- mc,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var folder;
-var thread1, thread2, thread3;
-
-function setupModule(module) {
- folder = create_folder("WatchIgnoreThreadTest");
- thread1 = create_thread(3);
- thread2 = create_thread(4);
- thread3 = create_thread(5);
- add_sets_to_folders([folder], [thread1, thread2, thread3]);
-
- be_in_folder(folder);
- make_display_threaded();
- expand_all_threads();
-}
-
-/**
- * Click one of the menu items in the appmenu View | Messages menu.
- * @param {string} menuId The id of the menu item to click.
- */
-function clickViewMessagesItem(menuId) {
- mc.click_through_appmenu(
- [{ id: "appmenu_View" }, { id: "appmenu_viewMessagesMenu" }],
- { id: menuId }
- );
-}
-
-/**
- * Test that Ignore Thread works as expected.
- */
-function test_ignore_thread() {
- let t1root = thread1.getMsgHdr(0);
-
- let t1second = select_click_row(1);
- assert_selected_and_displayed(t1second);
-
- // Ignore this thread.
- mc.keypress(null, "K", { shiftKey: false, accelKey: false });
-
- // The first msg in the next thread should now be selected.
- let t2root = thread2.getMsgHdr(0);
- assert_selected_and_displayed(t2root);
-
- // The ignored thread should still be visible (with an ignored icon).
- assert_visible(t1root);
-
- // Go to another folder then back. Ignored messages should now be hidden.
- be_in_folder(inboxFolder);
- be_in_folder(folder);
- select_click_row(0);
- assert_selected_and_displayed(t2root);
-}
-
-/**
- * Test that ignored threads are shown when the View | Threads |
- * Ignored Threads option is checked.
- */
-function test_view_threads_ignored_threads() {
- let t1root = thread1.getMsgHdr(0);
- let t2root = thread2.getMsgHdr(0);
-
- // Check "Ignored Threads" - the ignored messages should appear =>
- // the first row is the first message of the first thread.
- clickViewMessagesItem("appmenu_viewIgnoredThreadsMenuItem");
- select_click_row(0);
- assert_selected_and_displayed(t1root);
-
- // Uncheck "Ignored Threads" - the ignored messages should get hidden.
- clickViewMessagesItem("appmenu_viewIgnoredThreadsMenuItem");
- select_click_row(0);
- assert_selected_and_displayed(t2root);
- assert_not_shown(thread1.msgHdrList);
-}
-
-/**
- * Test that Watch Thread makes the thread watched.
- */
-function test_watch_thread() {
- let t2second = select_click_row(1);
- let t3root = thread3.getMsgHdr(0);
- assert_selected_and_displayed(t2second);
-
- // Watch this thread.
- mc.keypress(null, "W", { shiftKey: false, accelKey: false });
-
- // Choose "Watched Threads with Unread".
- clickViewMessagesItem("appmenu_viewWatchedThreadsWithUnreadMenuItem");
- select_click_row(1);
- assert_selected_and_displayed(t2second);
- assert_not_shown(thread1.msgHdrList);
- assert_not_shown(thread3.msgHdrList);
-
- // Choose "All Messages" again.
- clickViewMessagesItem("appmenu_viewAllMessagesMenuItem");
- assert_not_shown(thread1.msgHdrList); // still ignored (and now shown)
- select_click_row(thread2.msgHdrList.length);
- assert_selected_and_displayed(t3root);
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-pane/test-display-message-with-folder-modes.js
+++ /dev/null
@@ -1,220 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test that displaying messages in folder tabs works correctly with folder
- * modes. This includes:
- * - switching to the default folder mode if the folder isn't present in the
- * current folder mode
- * - not switching otherwise
- * - making sure that we're able to expand the right folders in the smart folder
- * mode
- */
-
-"use strict";
-
-var {
- assert_folder_child_in_view,
- assert_folder_collapsed,
- assert_folder_expanded,
- assert_folder_mode,
- assert_folder_not_visible,
- assert_folder_selected_and_displayed,
- assert_folder_tree_view_row_count,
- assert_folder_visible,
- assert_message_not_in_view,
- assert_selected_and_displayed,
- be_in_folder,
- collapse_folder,
- display_message_in_folder_tab,
- get_smart_folder_named,
- inboxFolder,
- make_new_sets_in_folder,
- mc,
- select_none,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var folder;
-var dummyFolder;
-var inbox2Folder;
-var smartInboxFolder;
-
-var msgHdr;
-
-function setupModule(module) {
- assert_folder_mode("all");
- assert_folder_tree_view_row_count(7);
-
- // This is a subfolder of the inbox so that
- // test_display_message_in_smart_folder_mode_works is able to test that we
- // don't attempt to expand any inboxes.
- inboxFolder.createSubfolder("DisplayMessageWithFolderModesA", null);
- folder = inboxFolder.getChildNamed("DisplayMessageWithFolderModesA");
- // This second folder is meant to act as a dummy folder to switch to when we
- // want to not be in folder.
- inboxFolder.createSubfolder("DisplayMessageWithFolderModesB", null);
- dummyFolder = inboxFolder.getChildNamed("DisplayMessageWithFolderModesB");
- make_new_sets_in_folder(folder, [{ count: 5 }]);
- // The message itself doesn't really matter, as long as there's at least one
- // in the inbox. We will delete this in teardownModule because the inbox
- // is a shared resource and it's not okay to leave stuff in there.
- make_new_sets_in_folder(inboxFolder, [{ count: 1 }]);
-
- // Create another subfolder on the top level that is not a parent of the
- // 2 folders so that it is not visible in Favorite mode.
- inboxFolder.server.rootFolder.createSubfolder("Inbox2", null);
- inbox2Folder = inboxFolder.server.rootFolder.getChildNamed("Inbox2");
-
- be_in_folder(folder);
- msgHdr = mc.dbView.getMsgHdrAt(0);
-}
-
-/**
- * Test that displaying a message causes a switch to the default folder mode if
- * the folder isn't present in the current folder mode.
- */
-function test_display_message_with_folder_not_present_in_current_folder_mode() {
- // Make sure the folder doesn't appear in the favorite folder mode just
- // because it was selected last before switching
- be_in_folder(inboxFolder);
-
- // Move to favorite folders. This folder isn't currently a favorite folder
- mc.folderTreeView.mode = "favorite";
- assert_folder_not_visible(folder);
- assert_folder_not_visible(inboxFolder);
- assert_folder_not_visible(inbox2Folder);
-
- // Try displaying a message
- display_message_in_folder_tab(msgHdr);
-
- assert_folder_mode(mc.window.kDefaultMode);
- assert_folder_selected_and_displayed(folder);
- assert_selected_and_displayed(msgHdr);
-}
-
-/**
- * Test that displaying a message _does not_ cause a switch to the default
- * folder mode if the folder is present in the current folder mode.
- */
-function test_display_message_with_folder_present_in_current_folder_mode() {
- // Mark the folder as a favorite
- folder.setFlag(Ci.nsMsgFolderFlags.Favorite);
- // Also mark the dummy folder as a favorite, in preparation for
- // test_display_message_in_smart_folder_mode_works
- dummyFolder.setFlag(Ci.nsMsgFolderFlags.Favorite);
-
- // Make sure the folder doesn't appear in the favorite folder mode just
- // because it was selected last before switching
- be_in_folder(inboxFolder);
-
- // Switch to favorite folders. Check that the folder is now in the view, as is
- // the dummy folder
- mc.folderTreeView.mode = "favorite";
- assert_folder_visible(folder);
- assert_folder_visible(dummyFolder);
- // Also their parent folder should be visible.
- assert_folder_visible(inboxFolder);
- // But not a sibling of their parent, which is not Favorite.
- assert_folder_not_visible(inbox2Folder);
-
- // Try displaying a message
- display_message_in_folder_tab(msgHdr);
-
- assert_folder_mode("favorite");
- assert_folder_selected_and_displayed(folder);
- assert_selected_and_displayed(msgHdr);
-
- // Now unset the flags so that we don't affect later tests.
- folder.clearFlag(Ci.nsMsgFolderFlags.Favorite);
- dummyFolder.clearFlag(Ci.nsMsgFolderFlags.Favorite);
-}
-
-/**
- * Test that displaying a message in smart folders mode causes the parent in the
- * view to expand.
- */
-function test_display_message_in_smart_folder_mode_works() {
- // Clear the message selection, otherwise msgHdr will still be displayed and
- // display_message_in_folder_tab(msgHdr) will be a no-op.
- select_none();
- mc.folderTreeView.mode = "all";
-
- // Switch to the dummy folder, otherwise msgHdr will be in the view and the
- // display message in folder tab logic will simply select the message without
- // bothering to expand any folders.
- be_in_folder(dummyFolder);
-
- mc.folderTreeView.mode = "smart";
-
- let rootFolder = folder.server.rootFolder;
- // Check that the folder is actually the child of the account root
- assert_folder_child_in_view(folder, rootFolder);
-
- // Collapse everything
- smartInboxFolder = get_smart_folder_named("Inbox");
- collapse_folder(smartInboxFolder);
- assert_folder_collapsed(smartInboxFolder);
- collapse_folder(rootFolder);
- assert_folder_collapsed(rootFolder);
- assert_folder_not_visible(folder);
-
- // Try displaying the message
- display_message_in_folder_tab(msgHdr);
-
- // Check that the right folders have expanded
- assert_folder_mode("smart");
- assert_folder_collapsed(smartInboxFolder);
- assert_folder_expanded(rootFolder);
- assert_folder_selected_and_displayed(folder);
- assert_selected_and_displayed(msgHdr);
-}
-
-/**
- * Test that displaying a message in an inbox in smart folders mode causes the
- * message to be displayed in the smart inbox.
- */
-function test_display_inbox_message_in_smart_folder_mode_works() {
- be_in_folder(inboxFolder);
- let inboxMsgHdr = mc.dbView.getMsgHdrAt(0);
-
- // Collapse everything
- collapse_folder(smartInboxFolder);
- assert_folder_collapsed(smartInboxFolder);
- assert_folder_not_visible(inboxFolder);
- let rootFolder = folder.server.rootFolder;
- collapse_folder(rootFolder);
- assert_folder_collapsed(rootFolder);
-
- // Move to a different folder
- be_in_folder(get_smart_folder_named("Trash"));
- assert_message_not_in_view(inboxMsgHdr);
-
- // Try displaying the message
- display_message_in_folder_tab(inboxMsgHdr);
-
- // Check that nothing has expanded, and that the right folder is selected
- assert_folder_mode("smart");
- assert_folder_collapsed(smartInboxFolder);
- assert_folder_collapsed(rootFolder);
- assert_folder_selected_and_displayed(smartInboxFolder);
- assert_selected_and_displayed(inboxMsgHdr);
-}
-
-/**
- * Move back to the all folders mode.
- */
-function test_switch_to_all_folders() {
- mc.folderTreeView.mode = "all";
- assert_folder_tree_view_row_count(10);
-}
-
-function teardownModule() {
- // Remove our folders
- inboxFolder.propagateDelete(folder, true, null);
- inboxFolder.propagateDelete(dummyFolder, true, null);
- inboxFolder.server.rootFolder.propagateDelete(inbox2Folder, true, null);
- assert_folder_tree_view_row_count(7);
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-pane/test-folder-names-in-recent-mode.js
+++ /dev/null
@@ -1,97 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Test that the folder names have account name appended when in "recent" view.
- */
-
-"use strict";
-
-var {
- assert_folder_at_index_as,
- assert_folder_mode,
- assert_folder_tree_view_row_count,
- be_in_folder,
- make_new_sets_in_folder,
- mc,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-var { fixIterator } = ChromeUtils.import(
- "resource:///modules/iteratorUtils.jsm"
-);
-
-function setupModule(module) {
- assert_folder_mode("all");
- assert_folder_tree_view_row_count(7);
-}
-
-function test_folder_names_in_recent_view_mode() {
- // We need 2 local accounts that have pristine folders with
- // unmodified times, so that it does not influence the
- // list of Recent folders. So clear out the most-recently-used time.
- for (let acc of fixIterator(
- MailServices.accounts.accounts,
- Ci.nsIMsgAccount
- )) {
- for (let fld of fixIterator(
- acc.incomingServer.rootFolder.subFolders,
- Ci.nsIMsgFolder
- )) {
- fld.setStringProperty("MRUTime", "0");
- }
- }
-
- let acc1 = MailServices.accounts.accounts.queryElementAt(0, Ci.nsIMsgAccount);
- let acc2 = MailServices.accounts.accounts.queryElementAt(1, Ci.nsIMsgAccount);
- let rootFolder1 = acc1.incomingServer.rootFolder;
- let rootFolder2 = acc2.incomingServer.rootFolder;
-
- // Create some test folders.
- rootFolder1.createSubfolder("uniqueName", null);
- rootFolder1.createSubfolder("duplicatedName", null);
- rootFolder2.createSubfolder("duplicatedName", null);
- let inbox2 = rootFolder2.getFolderWithFlags(Ci.nsMsgFolderFlags.Inbox);
- inbox2.createSubfolder("duplicatedName", null);
-
- let fUnique = rootFolder1.getChildNamed("uniqueName");
- let fDup1 = rootFolder1.getChildNamed("duplicatedName");
- let fDup2 = rootFolder2.getChildNamed("duplicatedName");
- let fDup3 = inbox2.getChildNamed("duplicatedName");
- assert_folder_tree_view_row_count(10);
-
- // Create some messages in the folders to make them recently used.
- make_new_sets_in_folder(fUnique, [{ count: 1 }]);
- be_in_folder(fUnique);
- make_new_sets_in_folder(fDup1, [{ count: 1 }]);
- be_in_folder(fDup1);
- make_new_sets_in_folder(fDup2, [{ count: 2 }]);
- be_in_folder(fDup2);
- make_new_sets_in_folder(fDup3, [{ count: 3 }]);
- be_in_folder(fDup3);
-
- mc.window.gFolderTreeView.mode = "recent_compact";
-
- // Check displayed folder names. In Recent mode the folders are sorted alphabetically
- assert_folder_at_index_as(0, "duplicatedName - Local Folders (1)");
- assert_folder_at_index_as(1, "duplicatedName - tinderbox@foo.invalid (3)");
- assert_folder_at_index_as(2, "duplicatedName - tinderbox@foo.invalid (2)");
- assert_folder_at_index_as(3, "uniqueName - Local Folders (1)");
- assert_folder_tree_view_row_count(4);
-
- // Remove our folders to clean up.
- rootFolder1.propagateDelete(fUnique, true, null);
- rootFolder1.propagateDelete(fDup1, true, null);
- rootFolder2.propagateDelete(fDup2, true, null);
- rootFolder2.propagateDelete(fDup3, true, null);
-}
-
-function teardownModule() {
- mc.window.gFolderTreeView.mode = "all";
- assert_folder_tree_view_row_count(7);
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-pane/test-folder-pane-consumers.js
+++ /dev/null
@@ -1,109 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Tests for other dialogs using the tree view implementation in folderPane.js.
- */
-
-"use strict";
-
-var { assert_true, mc } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { NNTP_PORT, setupLocalServer } = ChromeUtils.import(
- "resource://testing-common/mozmill/NNTPHelpers.jsm"
-);
-var { plan_for_modal_dialog, wait_for_modal_dialog } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-var nntpAccount;
-
-function setupModule(module) {
- let server = setupLocalServer(NNTP_PORT);
- nntpAccount = MailServices.accounts.FindAccountForServer(server);
-}
-
-function test_virtual_folder_selection_tree() {
- plan_for_modal_dialog(
- "mailnews:virtualFolderProperties",
- subtest_create_virtual_folder
- );
- mc.click_through_appmenu([{ id: "appmenu_new" }], {
- id: "appmenu_newVirtualFolder",
- });
-
- wait_for_modal_dialog("mailnews:virtualFolderProperties");
-}
-
-function subtest_create_virtual_folder(vfc) {
- // Open the folder chooser.
- plan_for_modal_dialog(
- "mailnews:virtualFolderList",
- subtest_check_virtual_folder_list
- );
- vfc.click(vfc.eid("folderListPicker"));
- wait_for_modal_dialog("mailnews:virtualFolderList");
-
- vfc.window.document.documentElement.querySelector("dialog").cancelDialog();
-}
-
-/**
- * Bug 464710
- * Check the folder list picker is not empty.
- */
-function subtest_check_virtual_folder_list(listc) {
- let tree = listc.e("folderPickerTree");
- // We should see the folders from the 2 base local accounts here.
- assert_true(
- tree.view.rowCount > 0,
- "Folder tree was empty in virtual folder selection!"
- );
- listc.window.document.documentElement.querySelector("dialog").cancelDialog();
-}
-
-function test_offline_sync_folder_selection_tree() {
- plan_for_modal_dialog("mailnews:synchronizeOffline", subtest_offline_sync);
-
- mc.click_through_appmenu(
- [{ id: "appmenu_File" }, { id: "appmenu_offline" }],
- { id: "appmenu_synchronizeOffline" }
- );
-
- wait_for_modal_dialog("mailnews:synchronizeOffline");
-}
-
-function subtest_offline_sync(osc) {
- // Open the folder chooser.
- plan_for_modal_dialog(
- "mailnews:selectOffline",
- subtest_check_offline_folder_list
- );
- osc.click(osc.eid("select"));
- wait_for_modal_dialog("mailnews:selectOffline");
-
- osc.window.document.documentElement.querySelector("dialog").cancelDialog();
-}
-
-/**
- * Bug 464710
- * Check the folder list picker is not empty.
- */
-function subtest_check_offline_folder_list(listc) {
- let tree = listc.e("synchronizeTree");
- // We should see the newsgroups from the NNTP server here.
- assert_true(
- tree.view.rowCount > 0,
- "Folder tree was empty in offline sync selection!"
- );
- listc.window.document.documentElement.querySelector("dialog").cancelDialog();
-}
-
-function teardownModule() {
- MailServices.accounts.removeAccount(nntpAccount);
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-pane/test-folder-pane.js
+++ /dev/null
@@ -1,119 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Tests for the folder pane, in particular the tree view. This is kept separate
- * from the main folder-display suite so that the folders created by other tests
- * there don't influence the results here.
- */
-
-"use strict";
-
-var {
- FAKE_SERVER_HOSTNAME,
- assert_folder_mode,
- assert_folder_tree_view_row_count,
- be_in_folder,
- collapse_folder,
- create_folder,
- enter_folder,
- expand_folder,
- mc,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var { MailUtils } = ChromeUtils.import("resource:///modules/MailUtils.jsm");
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-/**
- * Assert the Folder Pane is in All Folder mode by default. Check that the
- * correct number of rows for accounts and folders are always shown as new
- * folders are created, expanded, and collapsed.
- */
-function test_all_folders_toggle_folder_open_state() {
- // Test that we are in All Folders mode by default
- assert_folder_mode("all");
-
- let pop3Server = MailServices.accounts.FindServer(
- "tinderbox",
- FAKE_SERVER_HOSTNAME,
- "pop3"
- );
- collapse_folder(pop3Server.rootFolder);
- collapse_folder(MailServices.accounts.localFoldersServer.rootFolder);
-
- // All folders mode should give us only 2 rows to start
- // (tinderbox account and local folders)
- let accounts = 2;
- assert_folder_tree_view_row_count(accounts);
-
- let inbox = 1;
- let trash = 1;
- let outbox = 1;
- let archives = 1;
- let folderPaneA = 1;
- // Create archives folder - this is ugly, but essentially the same as
- // what mailWindowOverlay.js does. We can't use the built-in helper
- // method to create the folder because we need the archive flag to get
- // set before the folder added notification is sent out, which means
- // creating the folder object via RDF, setting the flag, and then
- // creating the storage, which sends the notification.
- let folder = MailUtils.getOrCreateFolder(
- pop3Server.rootFolder.URI + "/Archives"
- );
- folder.setFlag(Ci.nsMsgFolderFlags.Archive);
- folder.createStorageIfMissing(null);
- // After creating Archives, account should have expanded
- // so that we should have 5 rows visible
- assert_folder_tree_view_row_count(accounts + inbox + trash + archives);
- // close the tinderbox server.
- mc.folderTreeView.toggleOpenState(0);
- let folderA = create_folder("FolderPaneA");
- be_in_folder(folderA);
-
- // After creating our first folder we should have 6 rows visible
- assert_folder_tree_view_row_count(
- accounts + inbox + trash + outbox + folderPaneA
- );
-
- let oneFolderCount = mc.folderTreeView.rowCount;
-
- // This makes sure the folder can be toggled
- folderA.createSubfolder("FolderPaneB", null);
- let folderB = folderA.getChildNamed("FolderPaneB");
- // Enter folderB, then enter folderA. This makes sure that folderA is not
- // collapsed.
- enter_folder(folderB);
- enter_folder(folderA);
-
- // At this point folderA should be open, so the view should have one more
- // item than before (FolderPaneB).
- assert_folder_tree_view_row_count(oneFolderCount + 1);
-
- // Toggle the open state of folderA
- let index = mc.folderTreeView.getIndexOfFolder(folderA);
- mc.folderTreeView.toggleOpenState(index);
-
- // folderA should be collapsed so we are back to the original count
- assert_folder_tree_view_row_count(oneFolderCount);
-
- // Toggle it back to open
- mc.folderTreeView.toggleOpenState(index);
-
- // folderB should be visible again
- assert_folder_tree_view_row_count(oneFolderCount + 1);
-
- // Clean up
- expand_folder(pop3Server.rootFolder);
- folder.clearFlag(Ci.nsMsgFolderFlags.Archive);
- pop3Server.rootFolder.propagateDelete(folder, true, null);
- MailServices.accounts.localFoldersServer.rootFolder.propagateDelete(
- folderA,
- true,
- null
- );
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-tree-modes/test-custom-folder-tree-mode.js
+++ /dev/null
@@ -1,79 +0,0 @@
-/* -*- Mode: JavaScript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Tests for custom folder tree modes. The test mode is provided by the test
- * extension in the test-extension subdirectory.
- */
-
-"use strict";
-
-var {
- assert_folder_mode,
- assert_folder_visible,
- FAKE_SERVER_HOSTNAME,
- get_special_folder,
- mc,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var {
- close_window,
- plan_for_new_window,
- wait_for_new_window,
-} = ChromeUtils.import("resource://testing-common/mozmill/WindowHelpers.jsm");
-
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-var gInbox;
-
-function setupModule(module) {
- let server = MailServices.accounts.FindServer(
- "tinderbox",
- FAKE_SERVER_HOSTNAME,
- "pop3"
- );
- gInbox = get_special_folder(Ci.nsMsgFolderFlags.Inbox, false, server);
-}
-
-// Provided by the extension in test-extension
-var kTestModeID = "testmode";
-
-/**
- * Switch to the mode and verify that it displays correctly.
- */
-function test_switch_to_test_mode() {
- mc.folderTreeView.mode = kTestModeID;
- assert_folder_mode(kTestModeID);
- assert_folder_visible(gInbox);
-}
-
-/**
- * Open a new 3-pane window while the custom mode is selected, and make sure
- * that the mode displayed in the new window is the custom mode.
- */
-function test_open_new_window_with_custom_mode() {
- // Our selection may get lost while changing modes, and be_in_folder is
- // not sufficient to ensure actual selection.
- mc.folderTreeView.selectFolder(gInbox);
-
- plan_for_new_window("mail:3pane");
- mc.window.MsgOpenNewWindowForFolder(null, -1);
- let mc2 = wait_for_new_window("mail:3pane");
-
- assert_folder_mode(kTestModeID, mc2);
- assert_folder_visible(gInbox, mc2);
-
- close_window(mc2);
-}
-
-/**
- * Switch back to all folders.
- */
-function test_switch_to_all_folders() {
- mc.folderTreeView.mode = "all";
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-tree-modes/test-custom-smart-folder.js
+++ /dev/null
@@ -1,208 +0,0 @@
-/* -*- Mode: JavaScript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Tests for custom folder tree modes. The test mode is provided by the test
- * extension in the test-extension subdirectory.
- */
-
-"use strict";
-
-var {
- assert_folder_collapsed,
- assert_folder_displayed,
- assert_folder_expanded,
- assert_folder_mode,
- assert_folder_not_visible,
- assert_folder_selected_and_displayed,
- assert_folder_visible,
- collapse_folder,
- expand_folder,
- get_smart_folder_named,
- inboxFolder,
- make_new_sets_in_folder,
- mc,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-// spaces in the name are intentional
-var smartParentNameA = "My Smart Folder A";
-var smartParentNameB = "My Smart Folder B";
-
-var rootFolder;
-var inboxSubfolder, subfolderA, subfolderB;
-var smartFolderInbox;
-var smartFolderA;
-
-var nsMsgFolderFlags = Ci.nsMsgFolderFlags;
-
-/**
- * create two smart folder types and two real folders, one for each
- * smart folder type
- */
-function setupModule(module) {
- rootFolder = inboxFolder.server.rootFolder;
-
- // register a new smart folder type
- mc.folderTreeView
- .getFolderTreeMode("smart")
- .addSmartFolderType(smartParentNameA, false, false);
- mc.folderTreeView
- .getFolderTreeMode("smart")
- .addSmartFolderType(smartParentNameB, false, false);
-
- // Create a folder as a subfolder of the inbox
- inboxFolder.createSubfolder("smartFolderA", null);
- subfolderA = inboxFolder.getChildNamed("smartFolderA");
- inboxFolder.createSubfolder("smartFolderB", null);
- subfolderB = inboxFolder.getChildNamed("smartFolderB");
-
- // This is how folders are marked to match a custom smart folder
- // The name is added to a cache, as msgDatabase access in nsITreeView is
- // bad perf.
- mc.window.setSmartFolderName(subfolderA, smartParentNameA);
- mc.window.setSmartFolderName(subfolderB, smartParentNameB);
-
- // The message itself doesn't really matter, as long as there's at least one
- // in the folder.
- make_new_sets_in_folder(subfolderA, [{ count: 1 }]);
- make_new_sets_in_folder(subfolderB, [{ count: 1 }]);
-}
-
-/**
- * Switch to the smart folder mode, get the smart inbox.
- */
-function test_switch_to_smart_folder_mode() {
- mc.folderTreeView.mode = "smart";
- assert_folder_mode("smart");
-
- smartFolderA = get_smart_folder_named(smartParentNameA);
- mc.folderTreeView.selectFolder(smartFolderA);
-}
-
-function test_cache_property() {
- if (mc.window.getSmartFolderName(subfolderA) != smartParentNameA) {
- throw new Error("smartFolderName A cache property not set");
- }
- if (mc.window.getSmartFolderName(subfolderB) != smartParentNameB) {
- throw new Error("smartFolderName B cache property not set");
- }
-}
-
-function _test_smart_folder_type(folder, parentName) {
- let smartMode = mc.folderTreeView.getFolderTreeMode("smart");
- let [flag, name] = smartMode._getSmartFolderType(folder);
- if (flag != 0) {
- throw new Error(
- "custom smart folder definition [" + parentName + "] has a flag"
- );
- }
- if (name != parentName) {
- throw new Error(
- "custom smart folder [" +
- folder.name +
- "] is incorrect [" +
- name +
- "] should be [" +
- parentName +
- "]"
- );
- }
-}
-
-function test_smart_folder_type() {
- _test_smart_folder_type(subfolderA, smartParentNameA);
- _test_smart_folder_type(subfolderB, smartParentNameB);
-}
-
-/**
- * Test that our custom smart folders exist
- */
-
-function test_custom_folder_exists() {
- assert_folder_mode("smart");
- assert_folder_displayed(smartFolderA);
- // this is our custom smart folder parent created in folderPane.js
- mc.folderTreeView.selectFolder(subfolderA);
- assert_folder_selected_and_displayed(subfolderA);
-}
-
-function FTVItemHasChild(parentFTVItem, childFolder, recurse) {
- for (let child of parentFTVItem.children) {
- if (
- child._folder.URI == childFolder.URI ||
- (recurse && FTVItemHasChild(child, childFolder, recurse))
- ) {
- return true;
- }
- }
- return false;
-}
-
-/**
- * test that our real smart folder is in fact a child if the correct
- * smart folder parent
- */
-function test_smart_child_parent_relationship() {
- let folderIndex = assert_folder_visible(smartFolderA);
- let folderFTVItem = mc.folderTreeView.getFTVItemForIndex(folderIndex);
- if (!FTVItemHasChild(folderFTVItem, subfolderA, false)) {
- throw new Error(
- "Folder: " +
- subfolderA.name +
- " is not a child of our smart parent folder"
- );
- }
- assert_folder_mode("smart");
-}
-
-/**
- * test that our real smart folder is NOT a child of the smart inbox in the
- * tree view.
- */
-function test_real_child_parent_relationship() {
- smartFolderInbox = get_smart_folder_named("Inbox");
- expand_folder(smartFolderInbox);
- // the real parent should be an Inbox
- let folderIndex = assert_folder_visible(subfolderA.parent);
- let folderFTVItem = mc.folderTreeView.getFTVItemForIndex(folderIndex);
- // in the tree, subfolder is a child of our magic smart folder, and should not
- // be a child of inbox
- if (FTVItemHasChild(folderFTVItem, subfolderA, true)) {
- throw new Error(
- "Folder: " + subfolderA.name + " should not be a child of an inbox"
- );
- }
- assert_folder_mode("smart");
-}
-
-/**
- * test collapse/expand states of one of our smart folders
- */
-function test_smart_subfolder() {
- assert_folder_mode("smart");
- collapse_folder(smartFolderA);
- assert_folder_collapsed(smartFolderA);
- assert_folder_not_visible(subfolderA);
-
- expand_folder(smartFolderA);
- assert_folder_expanded(smartFolderA);
- assert_folder_visible(subfolderA);
-}
-
-/**
- * Switch back to all folders.
- */
-function test_return_to_all_folders() {
- assert_folder_mode("smart");
- mc.folderTreeView.mode = "all";
- assert_folder_mode("all");
-}
-
-function teardownModule() {
- inboxFolder.propagateDelete(subfolderA, true, null);
- inboxFolder.propagateDelete(subfolderB, true, null);
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-tree-modes/test-extension/bootstrap.js
+++ /dev/null
@@ -1,53 +0,0 @@
-/* -*- Mode: JavaScript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-var { ExtensionSupport } = ChromeUtils.import(
- "resource:///modules/ExtensionSupport.jsm"
-);
-
-// const addonID = "testfoldertreemode@mozilla.org";
-
-function install() {}
-
-function uninstall() {}
-
-function startup(data, reason) {
- ExtensionSupport.registerWindowListener(data.id, {
- chromeURLs: ["chrome://messenger/content/messenger.xhtml"],
- onLoadWindow: setupFolderMode,
- });
-}
-
-function shutdown(data, reason) {
- ExtensionSupport.unregisterWindowListener(data.id);
-}
-
-function setupFolderMode(aWindow) {
- let testFolderTreeMode = {
- __proto__: aWindow.IFolderTreeMode,
- generateMap(aFTV) {
- var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
- );
- // Pick the tinderbox@foo.invalid inbox and use it as the only folder
- let server = MailServices.accounts.FindServer(
- "tinderbox",
- "tinderbox123",
- "pop3"
- );
- let item = new aWindow.ftvItem(server.rootFolder.getChildNamed("Inbox"));
- item.__defineGetter__("children", () => []);
- return [item];
- },
- };
-
- aWindow.gFolderTreeView.registerFolderTreeMode(
- "testmode",
- testFolderTreeMode,
- "Test Mode"
- );
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-tree-modes/test-extension/manifest.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "manifest_version": 2,
- "applications": {
- "gecko": {
- "id": "testfoldertreemode@mozilla.org"
- }
- },
- "name": "Test Folder Modes",
- "version": "1.0",
- "description": "Provides a custom folder tree mode to be used by tests",
- "legacy": {
- "type": "bootstrap"
- }
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-tree-modes/test-mode-switching.js
+++ /dev/null
@@ -1,313 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Bug 978592.
- * Test that switching folder modes via menu works and also compact versions
- * can be toggled properly.
- */
-
-"use strict";
-
-var {
- assert_equals,
- assert_folder_not_visible,
- assert_folder_visible,
- assert_true,
- inboxFolder,
- make_new_sets_in_folder,
- mc,
- select_no_folders,
- toggle_main_menu,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var rootFolder;
-var unreadFolder;
-var favoriteFolder;
-var toggle_menu;
-var toggle_appmenu;
-var tree;
-var modeList_menu;
-var modeList_appmenu;
-var view_menu;
-var view_menupopup;
-var appmenu_button;
-var appmenu_mainView;
-var menu_state;
-
-function setupModule(module) {
- rootFolder = inboxFolder.server.rootFolder;
-
- // Create one folder with unread messages and one favorite folder.
- inboxFolder.createSubfolder("UnreadFolder", null);
- unreadFolder = inboxFolder.getChildNamed("UnreadFolder");
-
- inboxFolder.createSubfolder("FavoriteFolder", null);
- favoriteFolder = inboxFolder.getChildNamed("FavoriteFolder");
-
- make_new_sets_in_folder(unreadFolder, [{ count: 1 }]);
- favoriteFolder.setFlag(Ci.nsMsgFolderFlags.Favorite);
-
- toggle_menu = mc.e("menu_compactFolderView");
- toggle_appmenu = mc.e("appmenu_compactFolderView");
-
- modeList_menu = mc.e("menu_FolderViewsPopup");
- modeList_appmenu = mc.e("appMenu-foldersView");
-
- view_menu = mc.eid("menu_View");
- view_menupopup = mc.e("menu_View_Popup");
- appmenu_button = mc.eid("button-appmenu");
- appmenu_mainView = mc.e("appMenu-mainView");
-
- tree = mc.folderTreeView;
-
- select_no_folders();
- // Main menu is needed for this whole test file.
- menu_state = toggle_main_menu(true);
-}
-
-/**
- * Check if both "Compact view" checkboxes in menu are of the expected state.
- *
- * @param aChecked Boolean whether checkbox should be checked or not.
- * @param aDisabled Optional boolean whether the menuitem should be disabled..
- */
-function assert_compact_state(aChecked, aDisabled) {
- assert_equals(toggle_menu.hasAttribute("checked"), aChecked);
- assert_equals(toggle_appmenu.hasAttribute("checked"), aChecked);
- if (aDisabled != undefined) {
- assert_equals(toggle_menu.disabled, aDisabled);
- assert_equals(toggle_appmenu.disabled, aDisabled);
- }
-}
-
-/**
- * Check whether the expected folder mode is selected in menus and internally.
- *
- * @param aMode The name of the expected mode.
- */
-function assert_mode_selected(aMode) {
- assert_equals(tree.mode, aMode);
- let baseMode = tree.baseMode();
- assert_compact_state(baseMode != tree.mode);
- // We need to open the menu because only then the right mode is set in them.
- if (!mc.mozmillModule.isMac) {
- // On OS X the main menu seems not accessible for clicking from mozmill.
- mc.click(view_menu);
- let popuplist = mc.click_menus_in_sequence(
- view_menupopup,
- [{ id: modeList_menu.parentNode.id }],
- true
- );
- assert_true(
- modeList_menu
- .querySelector('[value="' + baseMode + '"]')
- .hasAttribute("checked")
- );
- mc.close_popup_sequence(popuplist);
- }
- mc.click_through_appmenu([
- { id: "appmenu_View" },
- { id: "appmenu_FolderViews" },
- ]);
-
- assert_true(
- modeList_appmenu
- .querySelector('[value="' + baseMode + '"]')
- .hasAttribute("checked")
- );
- // Close the appmenu by clicking the appmenu button again.
- mc.click(appmenu_button);
-}
-
-/**
- * Toggle the folder mode by clicking in the menu.
- *
- * @param mode The base name of the mode to select.
- */
-function select_mode_in_menu(mode) {
- mc.click_through_appmenu(
- [{ id: "appmenu_View" }, { id: "appmenu_FolderViews" }],
- { value: mode }
- );
-}
-
-/**
- * Toggle the Compact view option by clicking in the menu.
- */
-function toggle_compact_in_menu() {
- // For some reason, clicking the menuitem does not work by any means,
- // therefore we just simulate it here.
- let checked = toggle_appmenu.hasAttribute("checked");
- if (checked) {
- toggle_appmenu.removeAttribute("checked");
- } else {
- toggle_appmenu.setAttribute("checked", "true");
- }
-
- toggle_appmenu.doCommand();
-}
-
-/**
- * Check the all folders mode.
- */
-function subtest_switch_to_all_folders(aViaMenu) {
- const mode = "all";
- if (aViaMenu) {
- select_mode_in_menu(mode);
- } else {
- tree.mode = mode;
- }
-
- assert_mode_selected(mode);
- assert_compact_state(false, true);
-
- // This mode should be rejected as it doesn't exist.
- tree.mode = mode + "_compact";
- assert_mode_selected(mode);
-}
-
-/**
- * Check the unread folder mode.
- */
-function subtest_switch_to_unread_folders(aViaMenu) {
- const mode = "unread";
- if (aViaMenu) {
- select_mode_in_menu(mode);
- // We came from "favorites_compact" so just toggling to "unread"
- // in UI produces "unread_compact".
- assert_mode_selected(mode + "_compact");
- // OK, now turn "compact" off.
- toggle_compact_in_menu();
- } else {
- tree.mode = mode;
- }
-
- assert_mode_selected(mode);
- assert_compact_state(false, false);
-
- // Mode is hierarchical, parent folders are shown.
- assert_folder_visible(inboxFolder.server.rootFolder);
- assert_folder_visible(inboxFolder);
- assert_folder_visible(unreadFolder);
- assert_folder_not_visible(favoriteFolder);
-
- if (aViaMenu) {
- toggle_compact_in_menu();
- } else {
- tree.mode = mode + "_compact";
- }
-
- assert_mode_selected(mode + "_compact");
- // In compact mode parent folders are not shown.
- assert_folder_not_visible(inboxFolder.server.rootFolder);
- assert_folder_not_visible(inboxFolder);
- assert_folder_visible(unreadFolder);
- assert_folder_not_visible(favoriteFolder);
-}
-
-/**
- * Check the favorite folder mode.
- */
-function subtest_switch_to_favorite_folders(aViaMenu) {
- const mode = "favorite";
- if (aViaMenu) {
- select_mode_in_menu(mode);
- // We came from "unread_compact" so just toggling to "favorite"
- // in UI produces "favorite_compact".
- assert_mode_selected(mode + "_compact");
- // OK, now turn "compact" off.
- toggle_compact_in_menu();
- } else {
- tree.mode = mode;
- }
-
- assert_mode_selected(mode);
- assert_compact_state(false, false);
-
- // Mode is hierarchical, parent folders are shown.
- assert_folder_visible(inboxFolder.server.rootFolder);
- assert_folder_visible(inboxFolder);
- assert_folder_not_visible(unreadFolder);
- assert_folder_visible(favoriteFolder);
-
- if (aViaMenu) {
- toggle_compact_in_menu();
- } else {
- tree.mode = mode + "_compact";
- }
-
- assert_mode_selected(mode + "_compact");
- // In compact mode parent folders are not shown.
- assert_folder_not_visible(inboxFolder.server.rootFolder);
- assert_folder_not_visible(inboxFolder);
- assert_folder_not_visible(unreadFolder);
- assert_folder_visible(favoriteFolder);
-}
-
-/**
- * Check the recent folder mode.
- */
-function subtest_switch_to_recent_folders(aViaMenu) {
- const mode = "recent_compact";
- if (aViaMenu) {
- select_mode_in_menu("recent");
- } else {
- tree.mode = mode;
- }
-
- assert_mode_selected(mode);
- assert_compact_state(true, true);
-
- // This mode should be rejected as it doesn't exist.
- tree.mode = "recent";
- assert_mode_selected(mode);
-}
-
-/**
- * Check the smart folder mode.
- */
-function subtest_switch_to_smart_folders(aViaMenu) {
- const mode = "smart";
- if (aViaMenu) {
- select_mode_in_menu(mode);
- } else {
- tree.mode = mode;
- }
-
- assert_mode_selected(mode);
- assert_compact_state(false, true);
-
- // This mode should be rejected as it doesn't exist.
- tree.mode = mode + "_compact";
- assert_mode_selected(mode);
-}
-
-/**
- * Toggle folder modes through different means and sequences.
- */
-function test_toggling_modes() {
- subtest_switch_to_all_folders(false);
- subtest_switch_to_smart_folders(false);
-
- subtest_switch_to_unread_folders(false);
- subtest_switch_to_favorite_folders(false);
- subtest_switch_to_recent_folders(false);
-
- subtest_switch_to_unread_folders(true);
- subtest_switch_to_favorite_folders(true);
- subtest_switch_to_recent_folders(true);
-
- subtest_switch_to_smart_folders(true);
- subtest_switch_to_all_folders(true);
-}
-
-function teardownModule() {
- tree.mode = "all";
- inboxFolder.propagateDelete(unreadFolder, true, null);
- inboxFolder.propagateDelete(favoriteFolder, true, null);
- toggle_main_menu(menu_state);
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-tree-modes/test-smart-folders.js
+++ /dev/null
@@ -1,288 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test that the smart folder mode works properly. This includes checking
- * whether |getParentOfFolder| works, and also making sure selectFolder behaves
- * properly, opening the right folders.
- */
-
-"use strict";
-
-var {
- archive_selected_messages,
- assert_folder_child_in_view,
- assert_folder_collapsed,
- assert_folder_expanded,
- assert_folder_selected_and_displayed,
- be_in_folder,
- collapse_folder,
- delete_message_set,
- expand_folder,
- FAKE_SERVER_HOSTNAME,
- get_smart_folder_named,
- get_special_folder,
- inboxFolder,
- make_new_sets_in_folder,
- mc,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var { fixIterator } = ChromeUtils.import(
- "resource:///modules/iteratorUtils.jsm"
-);
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-var rootFolder;
-var inboxSubfolder;
-var trashFolder;
-var trashSubfolder;
-
-var smartInboxFolder;
-
-var inboxSet;
-
-function setupModule(module) {
- rootFolder = inboxFolder.server.rootFolder;
-
- // Create a folder as a subfolder of the inbox
- inboxFolder.createSubfolder("SmartFoldersA", null);
- inboxSubfolder = inboxFolder.getChildNamed("SmartFoldersA");
-
- trashFolder = inboxFolder.server.rootFolder.getFolderWithFlags(
- Ci.nsMsgFolderFlags.Trash
- );
- trashFolder.createSubfolder("SmartFoldersB", null);
- trashSubfolder = trashFolder.getChildNamed("SmartFoldersB");
-
- // The message itself doesn't really matter, as long as there's at least one
- // in the folder.
- [inboxSet] = make_new_sets_in_folder(inboxFolder, [{ count: 1 }]);
- make_new_sets_in_folder(inboxSubfolder, [{ count: 1 }]);
-}
-
-/**
- * Assert that the given folder is considered to be the container of the given
- * message header in this folder mode.
- */
-function assert_folder_for_msg_hdr(aMsgHdr, aFolder) {
- let actualFolder = mc.folderTreeView.getFolderForMsgHdr(aMsgHdr);
- if (actualFolder != aFolder) {
- throw new Error(
- "Message " +
- aMsgHdr.messageId +
- " should be contained in folder " +
- aFolder.URI +
- "in this view, but is actually contained in " +
- actualFolder.URI
- );
- }
-}
-
-/**
- * Switch to the smart folder mode.
- */
-function test_switch_to_smart_folders() {
- mc.folderTreeView.mode = "smart";
-
- // The smart inbox may not have been created at setupModule time, so get it
- // now
- smartInboxFolder = get_smart_folder_named("Inbox");
-}
-
-/**
- * Test the getParentOfFolder function.
- */
-function test_get_parent_of_folder() {
- // An inbox should have the special inbox as its parent
- assert_folder_child_in_view(inboxFolder, smartInboxFolder);
- // Similarly for the trash folder
- assert_folder_child_in_view(trashFolder, get_smart_folder_named("Trash"));
-
- // A child of the inbox (a shallow special folder) should have the account's
- // root folder as its parent
- assert_folder_child_in_view(inboxSubfolder, rootFolder);
- // A child of the trash (a deep special folder) should have the trash itself
- // as its parent
- assert_folder_child_in_view(trashSubfolder, trashFolder);
-
- // Subfolders of subfolders of the inbox should behave as normal
- inboxSubfolder.createSubfolder("SmartFoldersC", null);
- assert_folder_child_in_view(
- inboxSubfolder.getChildNamed("SmartFoldersC"),
- inboxSubfolder
- );
-}
-
-/**
- * Test the getFolderForMsgHdr function.
- */
-function test_get_folder_for_msg_hdr() {
- be_in_folder(inboxFolder);
- let inboxMsgHdr = mc.dbView.getMsgHdrAt(0);
- assert_folder_for_msg_hdr(inboxMsgHdr, smartInboxFolder);
-
- be_in_folder(inboxSubfolder);
- let inboxSubMsgHdr = mc.dbView.getMsgHdrAt(0);
- assert_folder_for_msg_hdr(inboxSubMsgHdr, inboxSubfolder);
-}
-
-/**
- * Test that selectFolder expands a collapsed smart inbox.
- */
-function test_select_folder_expands_collapsed_smart_inbox() {
- // Collapse the smart inbox
- collapse_folder(smartInboxFolder);
- assert_folder_collapsed(smartInboxFolder);
-
- // Also collapse the account root, make sure selectFolder don't expand it
- collapse_folder(rootFolder);
- assert_folder_collapsed(rootFolder);
-
- // Now attempt to select the folder.
- mc.folderTreeView.selectFolder(inboxFolder);
-
- assert_folder_collapsed(rootFolder);
- assert_folder_expanded(smartInboxFolder);
- assert_folder_selected_and_displayed(inboxFolder);
-}
-
-/**
- * Test that selectFolder expands a collapsed account root.
- */
-function test_select_folder_expands_collapsed_account_root() {
- // Collapse the account root
- collapse_folder(rootFolder);
- assert_folder_collapsed(rootFolder);
-
- // Also collapse the smart inbox, make sure selectFolder don't expand it
- collapse_folder(smartInboxFolder);
- assert_folder_collapsed(smartInboxFolder);
-
- // Now attempt to select the folder.
- mc.folderTreeView.selectFolder(inboxSubfolder);
-
- assert_folder_collapsed(smartInboxFolder);
- assert_folder_expanded(rootFolder);
- assert_folder_selected_and_displayed(inboxSubfolder);
-}
-
-/**
- * Test that smart folders are updated when the folders they should be
- * searching over are added/removed or have the relevant flag set/cleared.
- */
-function test_folder_flag_changes() {
- expand_folder(smartInboxFolder);
- // Now attempt to select the folder.
- mc.folderTreeView.selectFolder(inboxSubfolder);
- // Need to archive two messages in two different accounts in order to
- // create a smart Archives folder.
- select_click_row(0);
- archive_selected_messages();
- let pop3Server = MailServices.accounts.FindServer(
- "tinderbox",
- FAKE_SERVER_HOSTNAME,
- "pop3"
- );
- let pop3Inbox = get_special_folder(
- Ci.nsMsgFolderFlags.Inbox,
- false,
- pop3Server
- );
- make_new_sets_in_folder(pop3Inbox, [{ count: 1 }]);
- mc.folderTreeView.selectFolder(pop3Inbox);
- select_click_row(0);
- archive_selected_messages();
-
- let smartArchiveFolder = get_smart_folder_named("Archives");
- let archiveScope =
- "|" +
- smartArchiveFolder.msgDatabase.dBFolderInfo.getCharProperty(
- "searchFolderUri"
- ) +
- "|";
- // We should have both this account, and a folder corresponding
- // to this year in the scope.
- rootFolder = inboxFolder.server.rootFolder;
- let archiveFolder = rootFolder.getChildNamed("Archives");
- assert_folder_and_children_in_scope(archiveFolder, archiveScope);
- archiveFolder = pop3Server.rootFolder.getChildNamed("Archives");
- assert_folder_and_children_in_scope(archiveFolder, archiveScope);
-
- // Remove the archive flag, and make sure the archive folder and
- // its children are no longer in the search scope.
- archiveFolder.clearFlag(Ci.nsMsgFolderFlags.Archive);
-
- // Refresh the archive scope because clearing the flag should have
- // changed it.
- archiveScope =
- "|" +
- smartArchiveFolder.msgDatabase.dBFolderInfo.getCharProperty(
- "searchFolderUri"
- ) +
- "|";
-
- // figure out what we expect the archiveScope to now be.
- rootFolder = inboxFolder.server.rootFolder;
- let localArchiveFolder = rootFolder.getChildNamed("Archives");
- let allDescendants = localArchiveFolder.descendants;
- let desiredScope = "|" + localArchiveFolder.URI + "|";
- for (let folder of fixIterator(allDescendants, Ci.nsIMsgFolder)) {
- desiredScope += folder.URI + "|";
- }
-
- if (archiveScope != desiredScope) {
- throw new Error("archive scope wrong after removing folder");
- }
- assert_folder_and_children_not_in_scope(archiveFolder, archiveScope);
-}
-
-function assert_folder_and_children_in_scope(folder, searchScope) {
- let folderURI = "|" + folder.URI + "|";
- assert_uri_found(folderURI, searchScope);
- let allDescendants = folder.descendants;
- for (let folder of fixIterator(allDescendants, Ci.nsIMsgFolder)) {
- assert_uri_found(folder.URI, searchScope);
- }
-}
-
-function assert_folder_and_children_not_in_scope(folder, searchScope) {
- let folderURI = "|" + folder.URI + "|";
- assert_uri_not_found(folderURI, searchScope);
- let allDescendants = folder.descendants;
- for (let folder of fixIterator(allDescendants, Ci.nsIMsgFolder)) {
- assert_uri_not_found(folder.URI, searchScope);
- }
-}
-
-function assert_uri_found(folderURI, scopeList) {
- if (!scopeList.includes(folderURI)) {
- throw new Error("scope " + scopeList + "doesn't contain " + folderURI);
- }
-}
-
-function assert_uri_not_found(folderURI, scopeList) {
- if (scopeList.includes(folderURI)) {
- throw new Error(
- "scope " + scopeList + "contains " + folderURI + " but shouldn't"
- );
- }
-}
-
-/**
- * Move back to the all folders mode.
- */
-function test_switch_to_all_folders() {
- mc.folderTreeView.mode = "all";
-}
-
-function teardownModule() {
- inboxFolder.propagateDelete(inboxSubfolder, true, null);
- delete_message_set(inboxSet);
- trashFolder.propagateDelete(trashSubfolder, true, null);
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-tree-modes/test-unread-folders.js
+++ /dev/null
@@ -1,93 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test that the unread folder mode works properly. This includes making
- * sure that the selected folder is maintained correctly when the view
- * is rebuilt because a folder has become newly unread.
- */
-
-"use strict";
-
-var {
- assert_folder_visible,
- be_in_folder,
- delete_message_set,
- inboxFolder,
- make_new_sets_in_folder,
- mc,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var rootFolder;
-var inboxSubfolder;
-var trashFolder;
-var trashSubfolder;
-var inboxSet;
-
-function setupModule(module) {
- rootFolder = inboxFolder.server.rootFolder;
-
- // Create a folder as a subfolder of the inbox
- inboxFolder.createSubfolder("UnreadFoldersA", null);
- inboxSubfolder = inboxFolder.getChildNamed("UnreadFoldersA");
-
- trashFolder = inboxFolder.server.rootFolder.getFolderWithFlags(
- Ci.nsMsgFolderFlags.Trash
- );
- trashFolder.createSubfolder("UnreadFoldersB", null);
- trashSubfolder = trashFolder.getChildNamed("UnreadFoldersB");
-
- // The message itself doesn't really matter, as long as there's at least one
- // in the folder.
- [inboxSet] = make_new_sets_in_folder(inboxFolder, [{ count: 1 }]);
- make_new_sets_in_folder(inboxSubfolder, [{ count: 1 }]);
-}
-
-/**
- * Switch to the all folders mode.
- */
-function test_switch_to_all_folders() {
- mc.folderTreeView.mode = "all";
- be_in_folder(inboxFolder);
-}
-
-/**
- * Switch to the unread folder mode.
- */
-function test_switch_to_unread_folders() {
- mc.folderTreeView.mode = "unread";
-}
-
-/**
- * Test that inbox and inboxSubfolder are in view
- */
-function test_folder_population() {
- assert_folder_visible(inboxFolder);
- assert_folder_visible(inboxSubfolder);
-}
-
-/**
- * Test that a folder newly getting unread messages doesn't
- * change the selected folder in unread folders mode.
- */
-function test_newly_added_folder() {
- let [newSet] = make_new_sets_in_folder(trashFolder, [{ count: 1 }]);
- assert_folder_visible(trashFolder);
- if (mc.folderTreeView.getSelectedFolders()[0] != inboxFolder) {
- throw new Error(
- "Inbox folder should be selected after new unread folder" +
- " added to unread view"
- );
- }
- delete_message_set(newSet);
-}
-
-function teardownModule() {
- inboxFolder.propagateDelete(inboxSubfolder, true, null);
- delete_message_set(inboxSet);
- trashFolder.propagateDelete(trashSubfolder, true, null);
- mc.folderTreeView.mode = "all";
-}
deleted file mode 100644
--- a/mail/test/mozmill/folder-tree-modes/wrapper.py
+++ /dev/null
@@ -1,19 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-# We install an extension that provides a test folder tree mode.
-
-import os
-
-
-def on_before_start(profile):
- """
- This installs the extension in the test-extension subdirectory into the
- profile folder. We cannot use on_profile_created here because
- install_plugin/install_addon depends on the profile object being fully
- initialized.
- """
-
- profile.addons.install(
- [os.path.join(os.path.dirname(__file__), "test-extension")])
deleted file mode 100644
--- a/mail/test/mozmill/folder-widget/test-message-filters.js
+++ /dev/null
@@ -1,320 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test various properties of the message filters.
- */
-
-"use strict";
-
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-
-var { create_ldap_address_book } = ChromeUtils.import(
- "resource://testing-common/mozmill/AddressBookHelpers.jsm"
-);
-var {
- assert_equals,
- assert_false,
- assert_not_equals,
- assert_true,
- be_in_folder,
- close_popup,
- create_folder,
- make_new_sets_in_folder,
- mc,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { NNTP_PORT, setupLocalServer, setupNNTPDaemon } = ChromeUtils.import(
- "resource://testing-common/mozmill/NNTPHelpers.jsm"
-);
-var {
- close_window,
- plan_for_modal_dialog,
- plan_for_new_window,
- plan_for_window_close,
- wait_for_existing_window,
- wait_for_modal_dialog,
- wait_for_new_window,
- wait_for_window_focused,
- wait_for_window_close,
-} = ChromeUtils.import("resource://testing-common/mozmill/WindowHelpers.jsm");
-
-var { gMockPromptService } = ChromeUtils.import(
- "resource://testing-common/mozmill/PromptHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var folderA;
-
-function setupModule(module) {
- setupNNTPDaemon();
-
- folderA = create_folder("FolderToolbarA");
- // we need one message to select and open
- make_new_sets_in_folder(folderA, [{ count: 1 }]);
-
- setupLocalServer(NNTP_PORT);
-}
-
-/*
- * Test that the message filter list shows newsgroup servers.
- */
-function test_message_filter_shows_newsgroup_server() {
- be_in_folder(folderA);
-
- // Open the "Tools » Message Filters…" window,
- // a.k.a. "tasksMenu » filtersCmd".
- plan_for_new_window("mailnews:filterlist");
- mc.menus.Tools.filtersCmd.click();
- let filterc = wait_for_new_window("mailnews:filterlist");
- wait_for_window_focused(filterc.window);
-
- let popup = filterc.eid("serverMenuPopup");
- filterc.assertNode(popup);
- filterc.click(popup);
-
- let nntp = new elib.Elem(popup.node.children.item(2));
- filterc.assertNode(nntp);
- // We need to get the newsgroups to pop up somehow.
- // These all fail.
- // filterc.click(nntp);
- // filterc.mouseover(nntp);
- // filterc.select(popup, popup.node.parentNode.getIndexOfItem(nntp.node));
- // filterc.select(nntp, popup.node.parentNode.getIndexOfItem(nntp.node));
- // filterc.select(popup, 2);
- // let nntpPopup = new elib.Elem(nntp.node.menupopup);
- // filterc.click(nntpPopup);
- // filterc.mouseover(nntpPopup);
- // filterc.select(nntpPopup, 2);
-
- // This one initializes the menuitems, but it's kinda hacky.
- nntp.node.menupopup._ensureInitialized();
- assert_equals(
- nntp.node.itemCount,
- 5,
- "Incorrect number of children for the NNTP server"
- );
- close_window(filterc);
-}
-
-/*
- * Test that customizing the toolbar doesn't lead to doubled accounts in
- * the Get Mail menu. (bug 520457)
- */
-function test_customize_toolbar_doesnt_double_get_mail_menu() {
- be_in_folder(folderA);
-
- /**
- * Get the getAllNewMessages menu and check the number of items.
- */
- function check_getAllNewMsgMenu() {
- wait_for_window_focused(mc.window);
-
- const subview = mc.click_through_appmenu([
- { id: "appmenu_File" },
- { id: "appmenu_getNewMsgFor" },
- ]);
-
- assert_equals(
- subview.children.length,
- 5,
- "Incorrect number of items for GetNewMessages before customization"
- );
-
- // Close the appmenu.
- mc.click(mc.eid("button-appmenu"));
- }
-
- check_getAllNewMsgMenu();
-
- plan_for_new_window("mailnews:customizeToolbar");
- // Open the customization dialog.
- mc.rightClick(mc.eid("mail-bar3"));
- mc.click(mc.eid("CustomizeMailToolbar"));
- close_popup(mc, mc.eid("toolbar-context-menu"));
-
- let customc = wait_for_new_window("mailnews:customizeToolbar");
- wait_for_window_focused(customc.window);
- plan_for_window_close(customc);
- customc.click(customc.eid("donebutton"));
- wait_for_window_close();
-
- check_getAllNewMsgMenu();
-}
-test_customize_toolbar_doesnt_double_get_mail_menu.EXCLUDED_PLATFORMS = [
- "winnt",
- "darwin",
-];
-
-/* A helper function that opens up the new filter dialog (assuming that the
- * main filters dialog is already open), creates a simple filter, and then
- * closes the dialog.
- */
-function create_simple_filter() {
- // Open the "Tools » Message Filters…" window,
- // a.k.a. "tasksMenu » filtersCmd".
- mc.menus.Tools.filtersCmd.click();
-
- // We'll assume that the filters dialog is already open from
- // the previous tests.
- let filterc = wait_for_existing_window("mailnews:filterlist");
-
- function fill_in_filter_fields(fec) {
- let filterName = fec.e("filterName");
- filterName.value = "A Simple Filter";
- let searchAttr = fec.e("searchAttr0");
- let attrList = searchAttr.children[0];
- attrList.value = Ci.nsMsgSearchAttrib.To;
- let searchOp = fec.e("searchOp0");
- let opList = searchOp.children[0];
- opList.value = Ci.nsMsgSearchOp.Is;
- let searchValList = fec.e("searchVal0");
- let searchVal = searchValList.children[0];
- searchVal.setAttribute("value", "test@foo.invalid");
-
- let filterActions = fec.e("filterActionList");
- let firstAction = filterActions.getItemAtIndex(0);
- firstAction.setAttribute("value", "markasflagged");
- fec.e("FilterEditor").acceptDialog();
- }
-
- // Let's open the filter editor.
- plan_for_modal_dialog("mailnews:filtereditor", fill_in_filter_fields);
- filterc.click(filterc.eid("newButton"));
- wait_for_modal_dialog("mailnews:filtereditor");
-}
-
-/*
- * Test that the address books can appear in the message filter dropdown
- */
-function test_address_books_appear_in_message_filter_dropdown() {
- // Create a remote address book - we don't want this to appear in the
- // dropdown.
- let ldapAb = create_ldap_address_book("Some LDAP Address Book");
-
- // Sanity check - this LDAP book should be remote.
- assert_true(ldapAb.isRemote);
-
- // Open the "Tools » Message Filters…" window,
- // a.k.a. "tasksMenu » filtersCmd".
- mc.menus.Tools.filtersCmd.click();
-
- // We'll assume that the filters dialog is already open from
- // the previous tests.
- let filterc = wait_for_existing_window("mailnews:filterlist");
-
- // Prepare a function to deal with the filter editor once it
- // has opened
- function filterEditorOpened(fec) {
- let searchAttr = fec.e("searchAttr0");
- let attrList = searchAttr.children[0];
- attrList.value = Ci.nsMsgSearchAttrib.To;
- let searchOp = fec.e("searchOp0");
- let opList = searchOp.children[0];
- opList.value = Ci.nsMsgSearchOp.IsInAB;
- let searchValue = fec.e("searchVal0");
-
- // The magic number "4" is because the address book list is the
- // 4th child node of the search-value widget.
- let abList = searchValue.children[4];
-
- // We should have 2 address books here - one for the Personal Address
- // Book, and one for Collected Addresses. The LDAP address book should
- // not be shown, since it isn't a local address book.
- assert_equals(
- 2,
- abList.itemCount,
- "Did not display the correct number " +
- "of address books in the filter menu list."
- );
- }
-
- // Let's open the filter editor.
- plan_for_modal_dialog("mailnews:filtereditor", filterEditorOpened);
- filterc.click(filterc.eid("newButton"));
- wait_for_modal_dialog("mailnews:filtereditor");
-}
-
-/* Test that if the user has started running a filter, and the
- * "quit-application-requested" notification is fired, the user
- * is given a dialog asking whether or not to quit.
- *
- * This also tests whether or not cancelling quit works.
- */
-function test_can_cancel_quit_on_filter_changes() {
- // Register the Mock Prompt Service
- gMockPromptService.register();
-
- create_simple_filter();
-
- let filterc = wait_for_existing_window("mailnews:filterlist");
- let runButton = filterc.e("runFiltersButton");
- runButton.setAttribute("label", runButton.getAttribute("stoplabel"));
-
- let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance(
- Ci.nsISupportsPRBool
- );
-
- // Set the Mock Prompt Service to return false, so that we
- // cancel the quit.
- gMockPromptService.returnValue = false;
- // Trigger the quit-application-request notification
- Services.obs.notifyObservers(cancelQuit, "quit-application-requested");
- let promptState = gMockPromptService.promptState;
- assert_not_equals(null, promptState, "Expected a confirmEx prompt");
-
- assert_equals("confirmEx", promptState.method);
- // Since we returned false on the confirmation dialog,
- // we should be cancelling the quit - so cancelQuit.data
- // should now be true
- assert_true(cancelQuit.data, "Didn't cancel the quit");
-
- // Unregister the Mock Prompt Service
- gMockPromptService.unregister();
-}
-
-/* Test that if the user has started running a filter, and the
- * "quit-application-requested" notification is fired, the user
- * is given a dialog asking whether or not to quit.
- *
- * This also tests whether or not allowing quit works.
- */
-function test_can_quit_on_filter_changes() {
- // Register the Mock Prompt Service
- gMockPromptService.register();
-
- let filterc = wait_for_existing_window("mailnews:filterlist");
-
- // There should already be 1 filter defined from previous test.
- let filterCount = filterc.e("filterList").itemCount;
- assert_equals(filterCount, 1);
-
- let runButton = filterc.e("runFiltersButton");
- runButton.setAttribute("label", runButton.getAttribute("stoplabel"));
-
- let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance(
- Ci.nsISupportsPRBool
- );
-
- // Set the Mock Prompt Service to return true, so that we
- // allow the quit.
- gMockPromptService.returnValue = true;
- // Trigger the quit-application-request notification
- Services.obs.notifyObservers(cancelQuit, "quit-application-requested");
- let promptState = gMockPromptService.promptState;
- assert_not_equals(null, promptState, "Expected a confirmEx prompt");
-
- assert_equals("confirmEx", promptState.method);
- // Since we returned true on the confirmation dialog,
- // we should be allowing the quit - so cancelQuit.data
- // should now be false
- assert_false(cancelQuit.data, "Cancelled the quit");
-
- // Unregister the Mock Prompt Service
- gMockPromptService.unregister();
-}
deleted file mode 100644
--- a/mail/test/mozmill/im/test-chat-tab-restore.js
+++ /dev/null
@@ -1,89 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-var utils = ChromeUtils.import("chrome://mozmill/content/modules/utils.jsm");
-
-var { assert_tab_mode_name, mark_action, mc } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-/**
- * Create a new chat tab, making that tab the current tab. We block until the
- * message finishes loading. (Inspired by open_selected_message_in_new_tab)
- */
-function open_chat_tab() {
- // Get the current tab count so we can make sure the tab actually opened.
- let preCount = mc.tabmail.tabContainer.allTabs.length;
-
- mc.tabmail.openTab("chat", {});
- mark_action("imh", "open_chat_tab", []);
- wait_for_chat_tab_to_open(mc);
-
- if (mc.tabmail.tabContainer.allTabs.length != preCount + 1) {
- throw new Error("The tab never actually got opened!");
- }
-
- let newTab = mc.tabmail.tabInfo[preCount];
- return newTab;
-}
-
-function wait_for_chat_tab_to_open(aController) {
- if (aController == null) {
- aController = mc;
- }
-
- mark_action("imh", "wait_for_chat_tab_to_open", [aController]);
- utils.waitFor(
- function() {
- let chatTabFound = false;
- for (let tab of mc.tabmail.tabInfo) {
- if (tab.mode.type == "chat") {
- chatTabFound = true;
- break;
- }
- }
- return chatTabFound;
- },
- "Timeout waiting for chat tab to open",
- 1000,
- 50
- );
-
- // The above may return immediately, meaning the event queue might not get a
- // chance. Give it a chance now.
- aController.sleep(0);
- mark_action("imh", "/wait_for_chat_tab_to_open", []);
-}
-
-/*
- * This tests that the chat tab is restored properly after tabs are
- * serialized. As for folder tabs, we can't test a restart (can we ?), so we
- * just test the persist/restore cycle.
- */
-function test_chat_tab_restore() {
- // Close everything but the first tab.
- let closeTabs = function() {
- while (mc.tabmail.tabInfo.length > 1) {
- mc.tabmail.closeTab(1);
- }
- };
-
- open_chat_tab();
- let state = mc.tabmail.persistTabs();
- closeTabs();
- mc.tabmail.restoreTabs(state);
-
- if (mc.tabmail.tabContainer.allTabs.length < 2) {
- throw new Error("The tab is not restored!");
- }
-
- let tabTypes = ["folder", "chat"];
- for (let i in tabTypes) {
- assert_tab_mode_name(mc.tabmail.tabInfo[i], tabTypes[i]);
- }
-
- closeTabs();
-}
deleted file mode 100644
--- a/mail/test/mozmill/im/test-toolbar-buttons.js
+++ /dev/null
@@ -1,148 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-var {
- assert_equals,
- assert_false,
- assert_not_equals,
- assert_true,
- mc,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource:///modules/imServices.jsm");
-
-/* This test checks that the toolbar buttons of the chat toolbar are
- * correctly disabled/enabled, and that the placeholder displayed in
- * the middle of the chat tab is correct.
- */
-function test_toolbar_and_placeholder() {
- assert_not_equals(
- mc.tabmail.selectedTab.mode.type,
- "chat",
- "the chat tab shouldn't be selected at startup"
- );
- mc.click(mc.eid("button-chat"));
- assert_equals(
- mc.tabmail.selectedTab.mode.type,
- "chat",
- "the chat tab should be selected"
- );
-
- // Check that "No connected account" placeholder is correct.
- assert_equals(
- mc.e("conversationsDeck").selectedPanel.id,
- "noConvScreen",
- "'Your chat accounts are not connected.' placeholder"
- );
- assert_true(
- mc.e("noConvInnerBox").hidden,
- "the 'No conversation' placeholder is hidden"
- );
- assert_true(
- mc.e("noAccountInnerBox").hidden,
- "the 'No account' placeholder is hidden"
- );
- assert_false(
- mc.e("noConnectedAccountInnerBox").hidden,
- "the 'No connected account' placeholder is visible"
- );
- let chatHandler = mc.window.chatHandler;
- assert_equals(
- chatHandler._placeHolderButtonId,
- "openIMAccountManagerButton",
- "the correct placeholder button is visible"
- );
- assert_equals(
- mc.window.document.activeElement.id,
- chatHandler._placeHolderButtonId,
- "the placeholder button is focused"
- );
-
- // check that add contact and join chat are disabled
- assert_true(
- mc.e("button-add-buddy").disabled,
- "the Add Buddy button is disabled"
- );
- assert_true(
- mc.e("button-join-chat").disabled,
- "the Join Chat button is disabled"
- );
-
- // The next tests require an account, get the unwrapped default IRC account.
- let account = Services.accounts.getAccountByNumericId(1);
- assert_equals(
- account.protocol.id,
- "prpl-irc",
- "the default IM account is an IRC account"
- );
- let ircAccount = account.prplAccount.wrappedJSObject;
-
- // Pretend the account is connected and check how the UI reacts
- ircAccount.reportConnected();
-
- // check that add contact and join chat are no longer disabled
- assert_false(
- mc.e("button-add-buddy").disabled,
- "the Add Buddy button is not disabled"
- );
- assert_false(
- mc.e("button-join-chat").disabled,
- "the Join Chat button is not disabled"
- );
-
- // Check that the "No conversations" placeholder is correct.
- assert_false(
- mc.e("noConvInnerBox").hidden,
- "the 'No conversation' placeholder is visible"
- );
- assert_true(
- mc.e("noAccountInnerBox").hidden,
- "the 'No account' placeholder is hidden"
- );
- assert_true(
- mc.e("noConnectedAccountInnerBox").hidden,
- "the 'No connected account' placeholder is hidden"
- );
- assert_false(chatHandler._placeHolderButtonId, "no placeholder button");
-
- // Now check that the UI reacts to account disconnections too.
- ircAccount.reportDisconnected();
-
- // check that add contact and join chat are disabled again.
- assert_true(
- mc.e("button-add-buddy").disabled,
- "the Add Buddy button is disabled"
- );
- assert_true(
- mc.e("button-join-chat").disabled,
- "the Join Chat button is disabled"
- );
-
- // Check that the "No connected account" placeholder is back.
- assert_true(
- mc.e("noConvInnerBox").hidden,
- "the 'No conversation' placeholder is hidden"
- );
- assert_true(
- mc.e("noAccountInnerBox").hidden,
- "the 'No account' placeholder is hidden"
- );
- assert_false(
- mc.e("noConnectedAccountInnerBox").hidden,
- "the 'No connected account' placeholder is visible"
- );
- assert_equals(
- chatHandler._placeHolderButtonId,
- "openIMAccountManagerButton",
- "the correct placeholder button is visible"
- );
-
- while (mc.tabmail.tabInfo.length > 1) {
- mc.tabmail.closeTab(1);
- }
-}
deleted file mode 100644
--- a/mail/test/mozmill/instrumentation/test-instrument-setup.js
+++ /dev/null
@@ -1,96 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-
-var { assert_equals, mc } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { input_value } = ChromeUtils.import(
- "resource://testing-common/mozmill/KeyboardHelpers.jsm"
-);
-var {
- plan_for_window_close,
- wait_for_existing_window,
- wait_for_window_close,
-} = ChromeUtils.import("resource://testing-common/mozmill/WindowHelpers.jsm");
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-var user = {
- name: "Roger Sterling",
- email: "roger.sterling@example.com",
- incomingHost: "testin.example.com",
- outgoingHost: "testout.example.com",
-};
-
-function setupModule(module) {
- Services.prefs.setCharPref("mail.wizard.logging.dump", "All");
-
- // Set the pref to load a local autoconfig file.
- let url = collector.addHttpResource("../account/xml", "autoconfig");
- Services.prefs.setCharPref("mailnews.auto_config_url", url);
-
- // Force .com MIME-Type to text/xml
- collector.httpd.registerContentType("com", "text/xml");
-}
-
-function test_mail_account_setup() {
- let awc = wait_for_existing_window("mail:autoconfig");
-
- // Input user's account information
- awc.e("realname").focus();
- input_value(awc, user.name);
- awc.keypress(null, "VK_TAB", {});
- input_value(awc, user.email);
-
- // Load the autoconfig file from http://localhost:433**/autoconfig/example.com
- awc.e("next_button").click();
-
- // XXX: This should probably use a notification, once we fix bug 561143.
- awc.waitFor(
- () => awc.window.gEmailConfigWizard._currentConfig != null,
- "Timeout waiting for current config to become non-null",
- 8000,
- 600
- );
- plan_for_window_close(awc);
- awc.e("create_button").click();
-
- let events = mc.window.MailInstrumentation._currentState.events;
- wait_for_window_close();
-
- // we expect to have accountAdded and smtpServerAdded events.
- if (!events.accountAdded.data) {
- throw new Error("failed to add an account");
- } else if (!events.smtpServerAdded.data) {
- throw new Error("failed to add an smtp server");
- }
-}
-
-// Remove the accounts we added.
-function tearDownModule(module) {
- let incomingServer = MailServices.accounts.FindServer(
- "roger.sterling",
- user.incomingHost,
- "pop3"
- );
- assert_equals(incomingServer.hostName, user.incomingHost);
- let account = MailServices.accounts.FindAccountForServer(incomingServer);
-
- let identity = account.defaultIdentity;
- let outgoingServer = MailServices.smtp.getServerByKey(identity.smtpServerKey);
- assert_equals(outgoingServer.hostname, user.outgoingHost);
- MailServices.smtp.deleteServer(outgoingServer);
- MailServices.accounts.removeAccount(account, true);
-
- Services.prefs.clearUserPref("mailnews.auto_config_url");
-}
deleted file mode 100644
--- a/mail/test/mozmill/instrumentation/wrapper.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-# For test-instrumentation.js, we need to disable the account provisioner, or
-# else it will spawn immediately and block before we have a chance to run
-# any Mozmill tests.
-
-# We don't want any accounts for these tests.
-NO_ACCOUNTS = True
-
-PREFS = {
- "mail.provider.enabled": False,
-}
deleted file mode 100644
--- a/mail/test/mozmill/junk-commands/test-junk-commands.js
+++ /dev/null
@@ -1,97 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-var os = ChromeUtils.import("chrome://mozmill/content/stdlib/os.jsm");
-
-var {
- be_in_folder,
- create_folder,
- make_new_sets_in_folder,
- select_click_row,
- select_none,
- select_shift_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var {
- delete_mail_marked_as_junk,
- mark_selected_messages_as_junk,
-} = ChromeUtils.import("resource://testing-common/mozmill/JunkHelpers.jsm");
-
-// One folder's enough
-var folder = null;
-
-function setupModule(module) {
- folder = create_folder("JunkCommandsA");
- make_new_sets_in_folder(folder, [{ count: 30 }]);
-}
-
-/**
- * The number of messages to mark as junk and expect to be deleted.
- */
-var NUM_MESSAGES_TO_JUNK = 8;
-
-/**
- * Helper to check whether a folder has the right number of messages.
- *
- * @param aFolder the folder to check
- * @param aNumMessages the number of messages the folder should contain.
- */
-function _assert_folder_total_messages(aFolder, aNumMessages) {
- let curMessages = aFolder.getTotalMessages(false);
- if (curMessages != aNumMessages) {
- throw new Error(
- "The folder " +
- aFolder.prettyName +
- " should have " +
- aNumMessages +
- " messages, but actually has " +
- curMessages +
- " messages."
- );
- }
-}
-
-/**
- * Test deleting junk messages with no messages marked as junk.
- */
-function test_delete_no_junk_messages() {
- let initialNumMessages = folder.getTotalMessages(false);
- be_in_folder(folder);
- select_none();
- delete_mail_marked_as_junk(0);
- // Check if we still have the same number of messages
- _assert_folder_total_messages(folder, initialNumMessages);
-}
-
-/**
- * Test deleting junk messages with some messages marked as junk.
- */
-function test_delete_junk_messages() {
- let initialNumMessages = folder.getTotalMessages(false);
- be_in_folder(folder);
- select_click_row(1);
- let selectedMessages = select_shift_click_row(NUM_MESSAGES_TO_JUNK);
- // Mark these messages as junk
- mark_selected_messages_as_junk();
- // Now delete junk mail
- delete_mail_marked_as_junk(NUM_MESSAGES_TO_JUNK);
- // Check that we have the right number of messages left
- _assert_folder_total_messages(
- folder,
- initialNumMessages - NUM_MESSAGES_TO_JUNK
- );
- // Check that none of the message keys exist any more
- let db = folder.getDBFolderInfoAndDB({});
- for (let msgHdr of selectedMessages) {
- let key = msgHdr.messageKey;
- if (db.ContainsKey(key)) {
- throw new Error(
- "The database shouldn't contain key " + key + ", but does."
- );
- }
- }
-}
deleted file mode 100644
--- a/mail/test/mozmill/keyboard/test-spacehit.js
+++ /dev/null
@@ -1,94 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests that the space bar only advances to the next unread message
- * when mail.advance_on_spacebar is true (default).
- */
-
-"use strict";
-
-var {
- assert_equals,
- assert_not_equals,
- be_in_folder,
- create_folder,
- make_new_sets_in_folder,
- mc,
- select_click_row,
- wait_for_message_display_completion,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-// Get original preference value
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var prefName = "mail.advance_on_spacebar";
-var prefValue = Services.prefs.getBoolPref(prefName);
-
-function setupModule(module) {
- // Create four unread messages in a sample folder
- let folder = create_folder("Sample");
- make_new_sets_in_folder(folder, [{ count: 4 }]);
- be_in_folder(folder);
-}
-
-function teardownModule(module) {
- // Restore original preference value
- Services.prefs.setBoolPref(prefName, prefValue);
-}
-
-/**
- * The second of four simple messages is selected and [Shift-]Space is
- * pressed to determine if focus changes to a new message.
- *
- * @param aAdvance whether to advance
- * @param aShift whether to press Shift key
- */
-function subtest_advance_on_spacebar(aAdvance, aShift) {
- // Set preference
- Services.prefs.setBoolPref(prefName, aAdvance);
- // Select the second message
- let oldmessage = select_click_row(1);
- wait_for_message_display_completion(mc);
- // Press [Shift-]Space
- mc.keypress(null, " ", { shiftKey: aShift });
- // Check that message focus changes iff aAdvance is true
- let newmessage = mc.folderDisplay.selectedMessage;
- aAdvance
- ? assert_not_equals(oldmessage, newmessage)
- : assert_equals(oldmessage, newmessage);
-}
-
-/**
- * Test that focus remains on current message when preference is false
- * and spacebar is pressed.
- */
-function test_noadvance_on_space() {
- subtest_advance_on_spacebar(false, false);
-}
-
-/**
- * Test that focus remains on current message when preference is false
- * and shift-spacebar is pressed.
- */
-function test_noadvance_on_shiftspace() {
- subtest_advance_on_spacebar(false, true);
-}
-
-/**
- * Test that focus advances to next message when preference is true
- * and spacebar is pressed.
- */
-function test_advance_on_space() {
- subtest_advance_on_spacebar(true, false);
-}
-
-/**
- * Test that focus advances to previous message when preference is true
- * and shift-spacebar is pressed.
- */
-function test_advance_on_shiftspace() {
- subtest_advance_on_spacebar(true, true);
-}
deleted file mode 100644
--- a/mail/test/mozmill/message-header/evil-attached.eml
+++ /dev/null
@@ -1,22 +0,0 @@
-Date: Mon, 10 Jan 2011 12:00:00 -0500
-From: phisher@evil.com
-To: user@example.com
-Subject: Please look at this attachment!
-Content-Type: multipart/mixed; boundary="BOUNDARY"
-
-This is a multi-part message in MIME format.
---BOUNDARY
-Content-Type: text/html
-
-See below.
---BOUNDARY
-Content-Type: message/rfc822
-
-Date: Mon, 10 Jan 2011 12:00:00 -0500
-From: phisher@evil.com
-To: user@example.com
-Subject: Please click on this link!
-Content-Type: text/html
-
-<form action="http://localhost/download-me"><input></form>
---BOUNDARY--
deleted file mode 100644
--- a/mail/test/mozmill/message-header/evil.eml
+++ /dev/null
@@ -1,7 +0,0 @@
-Date: Mon, 10 Jan 2011 12:00:00 -0500
-From: phisher@evil.com
-To: user@example.com
-Subject: Please click on this link!
-Content-Type: text/html
-
-<form action="http://localhost/download-me"><input></form>
deleted file mode 100644
--- a/mail/test/mozmill/message-header/test-message-header.js
+++ /dev/null
@@ -1,1222 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Test functionality in the message header, e.g. tagging, contact editing,
- * the more button ...
- */
-
-"use strict";
-
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-
-var {
- create_address_book,
- create_mailing_list,
- ensure_no_card_exists,
- get_cards_in_all_address_books_for_email,
- get_mailing_list_from_address_book,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/AddressBookHelpers.jsm"
-);
-
-var {
- add_message_to_folder,
- assert_equals,
- assert_not_equals,
- assert_selected_and_displayed,
- assert_true,
- be_in_folder,
- close_popup,
- create_folder,
- create_message,
- gDefaultWindowHeight,
- mc,
- msgGen,
- restore_default_window_size,
- select_click_row,
- wait_for_message_display_completion,
- wait_for_popup_to_open,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { collapse_panes, element_visible_recursive } = ChromeUtils.import(
- "resource://testing-common/mozmill/DOMHelpers.jsm"
-);
-var { resize_to } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-var folder, folderMore;
-var gInterestingMessage;
-
-/**
- * Wraps a call to querySelector in an elib.Elem.
- */
-const getElement = (elem, query) => new elib.Elem(elem.querySelector(query));
-
-function setupModule(module) {
- folder = create_folder("MessageWindowA");
- folderMore = create_folder("MesageHeaderMoreButton");
-
- // create a message that has the interesting headers that commonly
- // show up in the message header pane for testing
- gInterestingMessage = create_message({
- cc: msgGen.makeNamesAndAddresses(20), // YYY
- subject:
- "This is a really, really, really, really, really, really, really, really, long subject.",
- clobberHeaders: {
- Newsgroups: "alt.test",
- "Reply-To": "J. Doe <j.doe@momo.invalid>",
- "Content-Base": "http://example.com/",
- Bcc: "Richard Roe <richard.roe@momo.invalid>",
- },
- });
-
- add_message_to_folder(folder, gInterestingMessage);
-
- // create a message that has more to and cc addresses than visible in the
- // tooltip text of the more button
- let msgMore1 = create_message({
- to: msgGen.makeNamesAndAddresses(40),
- cc: msgGen.makeNamesAndAddresses(40),
- });
- add_message_to_folder(folderMore, msgMore1);
-
- // create a message that has more to and cc addresses than visible in the
- // header
- let msgMore2 = create_message({
- to: msgGen.makeNamesAndAddresses(20),
- cc: msgGen.makeNamesAndAddresses(20),
- });
- add_message_to_folder(folderMore, msgMore2);
-
- // create a message that has boring headers to be able to switch to and
- // back from, to force the more button to collapse again.
- let msg = create_message();
- add_message_to_folder(folder, msg);
-
- // Some of these tests critically depends on the window width, collapse
- // everything that might be in the way
- collapse_panes(mc.e("folderpane_splitter"), true);
- collapse_panes(mc.e("tabmail-container"), true);
-
- // Disable animations on the panel, so that we don't have to deal with
- // async openings.
- let contactPanel = mc.eid("editContactPanel").getNode();
- contactPanel.setAttribute("animate", false);
-
- test_a11y_attrs.__force_skip__ = true; // disabled for now, see bug 1489748
-}
-
-function teardownModule(module) {
- let contactPanel = mc.eid("editContactPanel").getNode();
- contactPanel.removeAttribute("animate");
-
- // Now restore the panes we hid in setupModule
- collapse_panes(mc.e("folderpane_splitter"), false);
- collapse_panes(mc.e("tabmail-container"), false);
-}
-
-/**
- * Helper function that takes an array of mail-emailaddress elements and
- * returns the last one in the list that is not hidden. Returns null if no
- * such element exists.
- *
- * @param aAddrs an array of mail-emailaddress elements.
- */
-function get_last_visible_address(aAddrs) {
- for (let i = aAddrs.length - 1; i >= 0; --i) {
- if (!aAddrs[i].hidden) {
- return aAddrs[i];
- }
- }
- return null;
-}
-
-function test_add_tag_with_really_long_label() {
- be_in_folder(folder);
-
- // select the first message, which will display it
- let curMessage = select_click_row(0);
-
- assert_selected_and_displayed(mc, curMessage);
-
- let topColumn = mc.eid("expandedfromTableHeader").node;
- let bottomColumn = mc.eid("expandedsubjectTableHeader").node;
-
- if (topColumn.clientWidth != bottomColumn.clientWidth) {
- throw new Error(
- "Header columns have different widths! " +
- topColumn.clientWidth +
- " != " +
- bottomColumn.clientWidth
- );
- }
- let defaultWidth = topColumn.clientWidth;
-
- // Make the tags label really long.
- let tagsLabel = mc.eid("expandedtagsLabel").node;
- let oldTagsValue = tagsLabel.value;
- tagsLabel.value = "taaaaaaaaaaaaaaaaaags";
-
- if (topColumn.clientWidth != bottomColumn.clientWidth) {
- tagsLabel.value = oldTagsValue;
- throw new Error(
- "Header columns have different widths! " +
- topColumn.clientWidth +
- " != " +
- bottomColumn.clientWidth
- );
- }
- if (topColumn.clientWidth != defaultWidth) {
- tagsLabel.value = oldTagsValue;
- throw new Error(
- "Header columns changed width! " +
- topColumn.clientWidth +
- " != " +
- defaultWidth
- );
- }
-
- // Add the first tag, and make sure that the label are the same length.
- mc.keypress(mc.eid("expandedfromTableHeader"), "1", {});
- if (topColumn.clientWidth != bottomColumn.clientWidth) {
- tagsLabel.value = oldTagsValue;
- throw new Error(
- "Header columns have different widths! " +
- topColumn.clientWidth +
- " != " +
- bottomColumn.clientWidth
- );
- }
- if (topColumn.clientWidth == defaultWidth) {
- tagsLabel.value = oldTagsValue;
- throw new Error(
- "Header columns didn't change width! " +
- topColumn.clientWidth +
- " == " +
- defaultWidth
- );
- }
-
- // Remove the tag and put it back so that the a11y label gets regenerated
- // with the normal value rather than "taaaaaaaags"
- tagsLabel.value = oldTagsValue;
- mc.keypress(mc.eid("expandedfromTableHeader"), "1", {});
- mc.keypress(mc.eid("expandedfromTableHeader"), "1", {});
-}
-
-/**
- * @param headerName used for pretty-printing in exceptions
- * @param headerValueElement Function returning the DOM element
- * with the data.
- * @param expectedName Function returning the expected value of
- * nsIAccessible.name for the DOM element in question
- * @param expectedRole the expected value for nsIAccessible.role
- */
-let headersToTest = [
- {
- headerName: "Subject",
- headerValueElement(mc) {
- return mc.e("expandedsubjectBox", { class: "headerValue" });
- },
- expectedName(mc, headerValueElement) {
- return (
- mc.e("expandedsubjectLabel").value +
- ": " +
- headerValueElement.textContent
- );
- },
- expectedRole: Ci.nsIAccessibleRole.ROLE_ENTRY,
- },
- {
- headerName: "Content-Base",
- headerValueElement(mc) {
- return mc.window.document.querySelector(
- "#expandedcontent-baseBox > .headerValue.text-link.headerValueUrl"
- );
- },
- expectedName(mc, headerValueElement) {
- return (
- mc.e("expandedcontent-baseLabel").value +
- ": " +
- headerValueElement.textContent
- );
- },
- expectedRole: Ci.nsIAccessibleRole.ROLE_ENTRY,
- },
- {
- headerName: "From",
- headerValueElement(mc) {
- return mc.window.document.querySelector(
- "#expandedfromBox > mail-emailaddress.emailDisplayButton"
- );
- },
- expectedName(mc, headerValueElement) {
- return (
- mc.e("expandedfromLabel").value +
- ": " +
- headerValueElement.parentNode.getAttribute("fullAddress")
- );
- },
- expectedRole: Ci.nsIAccessibleRole.ROLE_ENTRY,
- },
- {
- headerName: "To",
- headerValueElement(mc) {
- return mc.window.document.querySelector(
- "#expandedtoBox > mail-emailaddress.emailDisplayButton"
- );
- },
- expectedName(mc, headerValueElement) {
- return (
- mc.e("expandedtoLabel").value +
- ": " +
- headerValueElement.parentNode.getAttribute("fullAddress")
- );
- },
- expectedRole: Ci.nsIAccessibleRole.ROLE_ENTRY,
- },
- {
- headerName: "Cc",
- headerValueElement(mc) {
- return mc.window.document.querySelector(
- "#expandedccBox > mail-emailaddress.emailDisplayButton"
- );
- },
- expectedName(mc, headerValueElement) {
- return (
- mc.e("expandedccLabel").value +
- ": " +
- headerValueElement.parentNode.getAttribute("fullAddress")
- );
- },
- expectedRole: Ci.nsIAccessibleRole.ROLE_ENTRY,
- },
- {
- headerName: "Bcc",
- headerValueElement(mc) {
- return mc.window.document.querySelector(
- "#expandedbccBox > mail-emailaddress.emailDisplayButton"
- );
- },
- expectedName(mc, headerValueElement) {
- return (
- mc.e("expandedbccLabel").value +
- ": " +
- headerValueElement.parentNode.getAttribute("fullAddress")
- );
- },
- expectedRole: Ci.nsIAccessibleRole.ROLE_ENTRY,
- },
- {
- headerName: "Reply-To",
- headerValueElement(mc) {
- return mc.window.document.querySelector(
- "#expandedreply-toBox > mail-emailaddress.emailDisplayButton"
- );
- },
- expectedName(mc, headerValueElement) {
- return (
- mc.e("expandedreply-toLabel").value +
- ": " +
- headerValueElement.parentNode.getAttribute("fullAddress")
- );
- },
- expectedRole: Ci.nsIAccessibleRole.ROLE_ENTRY,
- },
- {
- headerName: "Newsgroups",
- headerValueElement(mc) {
- return mc.window.document.querySelector(
- "#expandednewsgroupsBox > mail-newsgroup.newsgrouplabel"
- );
- },
- expectedName(mc, headerValueElement) {
- return (
- mc.e("expandednewsgroupsLabel").value +
- ": " +
- headerValueElement.parentNode.parentNode.getAttribute("newsgroup")
- );
- },
- expectedRole: Ci.nsIAccessibleRole.ROLE_ENTRY,
- },
- {
- headerName: "Tags",
- headerValueElement(mc) {
- return mc.window.document.querySelector(
- "#expandedtagsBox > .tagvalue.blc-FF0000"
- );
- },
- expectedName(mc, headerValueElement) {
- return (
- mc.e("expandedtagsLabel").value +
- ": " +
- headerValueElement.getAttribute("value")
- );
- },
- expectedRole: Ci.nsIAccessibleRole.ROLE_LABEL,
- },
-];
-
-// used to get the accessible object for a DOM node
-let gAccService = Cc["@mozilla.org/accessibilityService;1"].getService(
- Ci.nsIAccessibilityService
-);
-
-/**
- * Use the information from aHeaderInfo to verify that screenreaders will
- * do the right thing with the given message header.
- *
- * @param {Object} aHeaderInfo Information about how to do the verification;
- * See the comments above the headersToTest array
- * for details.
- */
-function verify_header_a11y(aHeaderInfo) {
- let headerValueElement = aHeaderInfo.headerValueElement(mc);
- assert_not_equals(
- headerValueElement,
- null,
- `element not found for header '${aHeaderInfo.headerName}'`
- );
-
- let headerAccessible;
- mc.waitFor(
- () =>
- (headerAccessible = gAccService.getAccessibleFor(headerValueElement)) !=
- null,
- `didn't find accessible element for header '${aHeaderInfo.headerName}'`
- );
-
- assert_equals(
- headerAccessible.role,
- aHeaderInfo.expectedRole,
- `role for ${aHeaderInfo.headerName} was ${headerAccessible.role}; ` +
- `should have been ${aHeaderInfo.expectedRole}`
- );
-
- let expectedName = aHeaderInfo.expectedName(mc, headerValueElement);
- assert_equals(
- headerAccessible.name,
- expectedName,
- `headerAccessible.name for ${aHeaderInfo.headerName} ` +
- `was '${headerAccessible.name}'; expected '${expectedName}'`
- );
-}
-
-/**
- * Test the accessibility attributes of the various message headers.
- *
- * XXX This test used to be after test_more_button_with_many_recipients,
- * however, there were some accessibility changes that it didn't seem to play
- * nicely with, and the toggling of the "more" button on the cc field was
- * causing this test to fail on the cc element. Tests with accessibility
- * hardware/software showed that the code was working fine. Therefore the test
- * may be suspect.
- *
- * XXX The gInterestingMessage has no tags until after
- * test_add_tag_with_really_long_label, so ensure it runs after that one.
- */
-function test_a11y_attrs() {
- be_in_folder(folder);
-
- // Convert the SyntheticMessage gInterestingMessage into an actual
- // nsIMsgDBHdr XPCOM message.
- let hdr = folder.msgDatabase.getMsgHdrForMessageID(
- gInterestingMessage.messageId
- );
-
- // select and open the interesting message
- let curMessage = select_click_row(mc.dbView.findIndexOfMsgHdr(hdr, false));
-
- // make sure it loads
- assert_selected_and_displayed(mc, curMessage);
-
- headersToTest.forEach(verify_header_a11y);
-}
-
-function test_more_button_with_many_recipients() {
- // Start on the interesting message.
- let curMessage = select_click_row(0);
-
- // make sure it loads
- wait_for_message_display_completion(mc);
- assert_selected_and_displayed(mc, curMessage);
-
- // Check the mode of the header.
- let headerBox = mc.eid("expandedHeaderView");
- let previousHeaderMode = headerBox.node.getAttribute("show_header_mode");
-
- // Click the "more" button.
- let moreIndicator = mc.window.document.getElementById("expandedccBox").more;
- moreIndicator.click();
-
- // Check the new mode of the header.
- if (headerBox.node.getAttribute("show_header_mode") != "all") {
- throw new Error(
- "Header Mode didn't change to 'all'! old=" +
- previousHeaderMode +
- ", new=" +
- headerBox.node.getAttribute("show_header_mode")
- );
- }
-
- // Switch to the boring message, to force the more button to collapse.
- curMessage = select_click_row(1);
-
- // make sure it loads
- wait_for_message_display_completion(mc);
- assert_selected_and_displayed(mc, curMessage);
-
- // Check the even newer mode of the header.
- if (headerBox.node.getAttribute("show_header_mode") != previousHeaderMode) {
- throw new Error(
- "Header Mode changed from " +
- previousHeaderMode +
- " to " +
- headerBox.node.getAttribute("show_header_mode") +
- " and didn't change back."
- );
- }
-}
-
-/**
- * Test that we can open up the inline contact editor when we
- * click on the star.
- */
-function test_clicking_star_opens_inline_contact_editor() {
- // Make sure we're in the right folder
- be_in_folder(folder);
- // Add a new message
- let msg = create_message();
- add_message_to_folder(folder, msg);
- // Open the latest message
- select_click_row(-1);
- wait_for_message_display_completion(mc);
- // Make sure the star is clicked, and we add the
- // new contact to our address book
- let toDescription = mc.window.document.getElementById("expandedtoBox")
- .emailAddresses;
-
- // Ensure that the inline contact editing panel is not open
- let contactPanel = mc.eid("editContactPanel").getNode();
- assert_not_equals(contactPanel.state, "open");
- subtest_more_widget_star_click(toDescription);
-
- // Ok, if we're here, then the star has been clicked, and
- // the contact has been added to our AB.
- let addrs = toDescription.getElementsByTagName("mail-emailaddress");
- let lastAddr = get_last_visible_address(addrs);
-
- // Click on the star, and ensure that the inline contact
- // editing panel opens
- mc.click(getElement(lastAddr, ".emailStar"));
- mc.waitFor(
- () => contactPanel.state == "open",
- () =>
- "Timeout waiting for contactPanel to open; state=" + contactPanel.state
- );
- contactPanel.hidePopup();
-}
-
-/**
- * Ensure that the specified element is visible/hidden
- *
- * @param id the id of the element to check
- * @param visible true if the element should be visible, false otherwise
- */
-function assert_shown(id, visible) {
- if (mc.e(id).hidden == visible) {
- throw new Error(
- '"' + id + '" should be ' + (visible ? "visible" : "hidden")
- );
- }
-}
-
-/**
- * Test that clicking references context menu works properly.
- */
-function test_msg_id_context_menu() {
- Services.prefs.setBoolPref("mailnews.headers.showReferences", true);
-
- // Add a new message
- let msg = create_message({
- clobberHeaders: {
- References:
- "<4880C986@example.com> <4880CAB2@example.com> <4880CC76@example.com>",
- },
- });
- add_message_to_folder(folder, msg);
- be_in_folder(folder);
-
- // Open the latest message.
- select_click_row(-1);
-
- // Right click to show the context menu.
- mc.rightClick(mc.eid("expandedreferencesBox", { tagName: "mail-messageid" }));
- wait_for_popup_to_open(mc.e("messageIdContext"));
-
- // Ensure Open Message For ID is shown... and that Open Browser With Message-ID
- // isn't shown.
- assert_shown("messageIdContext-openMessageForMsgId", true);
- assert_shown("messageIdContext-openBrowserWithMsgId", false);
-
- close_popup(mc, mc.eid("messageIdContext"));
-
- Services.prefs.setBoolPref("mailnews.headers.showReferences", false);
-}
-
-/**
- * Test that if a contact belongs to a mailing list within their
- * address book, then the inline contact editor will not allow
- * the user to change what address book the contact belongs to.
- * The editor should also show a message to explain why the
- * contact cannot be moved.
- */
-function test_address_book_switch_disabled_on_contact_in_mailing_list() {
- const MAILING_LIST_DIRNAME = "Some Mailing List";
- const ADDRESS_BOOK_NAME = "Some Address Book";
- // Add a new message
- let msg = create_message();
- add_message_to_folder(folder, msg);
-
- // Make sure we're in the right folder
- be_in_folder(folder);
-
- // Open the latest message
- select_click_row(-1);
-
- // Make sure the star is clicked, and we add the
- // new contact to our address book
- let toDescription = mc.window.document.getElementById("expandedtoBox")
- .emailAddresses;
-
- // Ensure that the inline contact editing panel is not open
- let contactPanel = mc.eid("editContactPanel").getNode();
- assert_not_equals(contactPanel.state, "open");
-
- subtest_more_widget_star_click(toDescription);
-
- // Ok, if we're here, then the star has been clicked, and
- // the contact has been added to our AB.
- let addrs = toDescription.getElementsByTagName("mail-emailaddress");
- let lastAddr = get_last_visible_address(addrs);
-
- // Click on the star, and ensure that the inline contact
- // editing panel opens
- mc.click(getElement(lastAddr, ".emailStar"));
- mc.waitFor(
- () => contactPanel.state == "open",
- () =>
- "Timeout waiting for contactPanel to open; state=" + contactPanel.state
- );
-
- let abDrop = mc.eid("editContactAddressBookList").getNode();
- let warningMsg = mc.eid("contactMoveDisabledText").getNode();
-
- // Ensure that the address book dropdown is not disabled
- assert_true(!abDrop.disabled);
- // We should not be displaying any warning
- assert_true(warningMsg.collapsed);
-
- // Now close the popup
- contactPanel.hidePopup();
-
- // For the contact that was added, create a mailing list in the
- // address book it resides in, and then add that contact to the
- // mailing list
- addrs = toDescription.getElementsByTagName("mail-emailaddress");
- let targetAddr = get_last_visible_address(addrs).getAttribute("emailAddress");
-
- let cards = get_cards_in_all_address_books_for_email(targetAddr);
-
- // There should be only one copy of this email address
- // in the address books.
- assert_equals(cards.length, 1);
- let card = cards[0];
-
- // Remove the card from any of the address books
- ensure_no_card_exists(targetAddr);
-
- // Add the card to a new address book, and insert it
- // into a mailing list under that address book
- let ab = create_address_book(ADDRESS_BOOK_NAME);
- ab.dropCard(card, false);
- let ml = create_mailing_list(MAILING_LIST_DIRNAME);
- ab.addMailList(ml);
-
- // Now we have to retrieve the mailing list from
- // the address book, in order for us to add and
- // delete cards from it.
- ml = get_mailing_list_from_address_book(ab, MAILING_LIST_DIRNAME);
- ml.addCard(card);
-
- // Re-open the inline contact editing panel
- mc.click(getElement(lastAddr, ".emailStar"));
- mc.waitFor(
- () => contactPanel.state == "open",
- () =>
- "Timeout waiting for contactPanel to open; state=" + contactPanel.state
- );
-
- // The dropdown should be disabled now
- assert_true(abDrop.disabled);
- // We should be displaying a warning
- assert_true(!warningMsg.collapsed);
-
- contactPanel.hidePopup();
-
- // And if we remove the contact from the mailing list, the
- // warning should be gone and the address book switching
- // menu re-enabled.
-
- let cardArray = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
- cardArray.appendElement(card);
- ml.deleteCards(cardArray);
-
- // Re-open the inline contact editing panel
- mc.click(getElement(lastAddr, ".emailStar"));
- mc.waitFor(
- () => contactPanel.state == "open",
- () =>
- "Timeout waiting for contactPanel to open; state=" + contactPanel.state
- );
-
- // Ensure that the address book dropdown is not disabled
- assert_true(!abDrop.disabled);
- // We should not be displaying any warning
- assert_true(warningMsg.collapsed);
-
- contactPanel.hidePopup();
-}
-
-/**
- * Test that clicking the adding an address node adds it to the address book.
- */
-function test_add_contact_from_context_menu() {
- // Click the contact to show the emailAddressPopup popup menu.
- mc.click(
- new elib.Elem(mc.e("expandedfromBox", { tagName: "mail-emailaddress" }))
- );
-
- var addToAddressBookItem = mc.window.document.getElementById(
- "addToAddressBookItem"
- );
- if (addToAddressBookItem.hidden) {
- throw new Error("addToAddressBookItem is hidden for unknown contact");
- }
- var editContactItem = mc.window.document.getElementById("editContactItem");
- if (!editContactItem.getAttribute("hidden")) {
- throw new Error("editContactItem is NOT hidden for unknown contact");
- }
-
- // Click the Add to Address Book context menu entry.
- mc.click(mc.eid("addToAddressBookItem"));
- // (for reasons unknown, the pop-up does not close itself)
- close_popup(mc, mc.eid("emailAddressPopup"));
-
- // Now click the contact again, the context menu should now show the
- // Edit Contact menu instead.
- mc.click(
- new elib.Elem(mc.e("expandedfromBox", { tagName: "mail-emailaddress" }))
- );
- // (for reasons unknown, the pop-up does not close itself)
- close_popup(mc, mc.eid("emailAddressPopup"));
-
- addToAddressBookItem = mc.window.document.getElementById(
- "addToAddressBookItem"
- );
- if (!addToAddressBookItem.hidden) {
- throw new Error("addToAddressBookItem is NOT hidden for known contact");
- }
- editContactItem = mc.window.document.getElementById("editContactItem");
- if (editContactItem.hidden) {
- throw new Error("editContactItem is hidden for known contact");
- }
-}
-
-function test_that_msg_without_date_clears_previous_headers() {
- be_in_folder(folder);
-
- // create a message: with descritive subject
- let msg = create_message({ subject: "this is without date" });
-
- // ensure that this message doesn't have a Date header
- delete msg.headers.Date;
-
- // this will add the message to the end of the folder
- add_message_to_folder(folder, msg);
-
- // Not the first anymore. The timestamp is that of "NOW".
- // select and open the LAST message
- let curMessage = select_click_row(-1);
-
- // make sure it loads
- wait_for_message_display_completion(mc);
- assert_selected_and_displayed(mc, curMessage);
-
- // Since we didn't give create_message an argument that would create a
- // Newsgroups header, the newsgroups <row> element should be collapsed.
- // However, since the previously displayed message _did_ have such a header,
- // certain bugs in the display of this header could cause the collapse
- // never to have happened.
- if (!mc.e("expandednewsgroupsRow").hasAttribute("hidden")) {
- throw new Error(
- "Expected <row> element for Newsgroups header to be " +
- "collapsed, but it wasn't\n!"
- );
- }
-}
-
-/**
- * Test various aspects of the (n more) widgetry.
- */
-function test_more_widget() {
- // generate message with 35 recips (effectively guarantees overflow for n=3)
- be_in_folder(folder);
- let msg = create_message({
- toCount: 35,
- subject: "Many To addresses to test_more_widget",
- });
-
- // add the message to the end of the folder
- add_message_to_folder(folder, msg);
-
- // select and open the injected message;
- // It is at the second last message in the display list.
- let curMessage = select_click_row(-2);
-
- // make sure it loads
- wait_for_message_display_completion(mc);
- assert_selected_and_displayed(mc, curMessage);
-
- // get the description element containing the addresses
- let toDescription = mc.window.document.getElementById("expandedtoBox")
- .emailAddresses;
-
- subtest_more_widget_display(toDescription);
- subtest_more_widget_click(toDescription);
- subtest_more_widget_star_click(toDescription);
-
- let showNLinesPref = Services.prefs.getIntPref(
- "mailnews.headers.show_n_lines_before_more"
- );
- Services.prefs.clearUserPref("mailnews.headers.show_n_lines_before_more");
- change_to_header_normal_mode();
- be_in_folder(folderMore);
-
- // first test a message with so many addresses that they don't fit in the
- // more widget's tooltip text
- msg = select_click_row(0);
- wait_for_message_display_completion(mc);
- assert_selected_and_displayed(mc, msg);
- subtest_more_button_tooltip(msg);
-
- // then test a message with so many addresses that they do fit in the
- // more widget's tooltip text
- msg = select_click_row(1);
- wait_for_message_display_completion(mc);
- assert_selected_and_displayed(mc, msg);
- subtest_more_button_tooltip(msg);
- Services.prefs.setIntPref(
- "mailnews.headers.show_n_lines_before_more",
- showNLinesPref
- );
-}
-
-/**
- * Test that all addresses are shown in show all header mode
- */
-function test_show_all_header_mode() {
- // generate message with 35 recips (effectively guarantees overflow for n=3)
- be_in_folder(folder);
- let msg = create_message({
- toCount: 35,
- subject: "many To addresses for test_show_all_header_mode",
- });
-
- // add the message to the end of the folder
- add_message_to_folder(folder, msg);
-
- // select and open the added message.
- // It is at the second last position in the display list.
- let curMessage = select_click_row(-2);
-
- // make sure it loads
- wait_for_message_display_completion(mc);
- assert_selected_and_displayed(mc, curMessage);
-
- // get the description element containing the addresses
- let toDescription = mc.window.document.getElementById("expandedtoBox")
- .emailAddresses;
-
- change_to_header_normal_mode();
- subtest_more_widget_display(toDescription);
- subtest_change_to_all_header_mode(toDescription);
- change_to_header_normal_mode();
- subtest_more_widget_click(toDescription);
-}
-
-function change_to_header_normal_mode() {
- // XXX Clicking on check menu items doesn't work in 1.4.1b1 (bug 474486)...
- // mc.click(new elib.Elem(mc.menus.View.viewheadersmenu.viewnormalheaders));
- // ... so call the function instead.
- mc.window.MsgViewNormalHeaders();
- mc.sleep(0);
-}
-
-function change_to_all_header_mode() {
- // XXX Clicking on check menu items doesn't work in 1.4.1b1 (bug 474486)...
- // mc.click(new elib.Elem(mc.menus.View.viewheadersmenu.viewallheaders));
- // ... so call the function instead.
- mc.window.MsgViewAllHeaders();
- mc.sleep(0);
-}
-
-/**
- * Get the number of lines in one of the multi-address fields
- * @param node the description element containing the addresses
- * @return the number of lines
- */
-function help_get_num_lines(node) {
- let style = mc.window.getComputedStyle(node);
- return style.height / style.lineHeight;
-}
-
-/**
- * Test that the "more" widget displays when it should.
- * @param toDescription the description node for the "to" field
- */
-function subtest_more_widget_display(toDescription) {
- // test that the to element doesn't have more than max lines
- let numLines = help_get_num_lines(toDescription);
-
- // get maxline pref
- let maxLines = Services.prefs.getIntPref(
- "mailnews.headers.show_n_lines_before_more"
- );
-
- // allow for a 15% tolerance for any padding that may be applied
- if (numLines < 0.85 * maxLines || numLines > 1.15 * maxLines) {
- throw new Error("expected == " + maxLines + "lines; found " + numLines);
- }
-
- // test that we've got a (more) node and that it's expanded
- let moreNode = mc.window.document.getElementById("expandedtoBox").more;
- if (!moreNode) {
- throw new Error("more node not found before activation");
- }
- if (moreNode.collapsed) {
- throw new Error("more node was collapsed when it should have been visible");
- }
-}
-
-/**
- * Test that clicking the "more" widget displays all the addresses.
- * @param toDescription the description node for the "to" field
- */
-function subtest_more_widget_click(toDescription) {
- let oldNumLines = help_get_num_lines(toDescription);
-
- // activate (n more)
- let moreNode = mc.window.document.getElementById("expandedtoBox").more;
- mc.click(new elib.Elem(moreNode));
-
- // test that (n more) is gone
- moreNode = mc.window.document.getElementById("expandedtoBox").more;
- if (!moreNode.collapsed) {
- throw new Error("more node should be collapsed after activation");
- }
-
- // test that we actually have more lines than we did before!
- let newNumLines = help_get_num_lines(toDescription);
- if (newNumLines <= oldNumLines) {
- throw new Error(
- "number of address lines present after more clicked = " +
- newNumLines +
- "<= number of lines present beforehand = " +
- oldNumLines
- );
- }
-}
-
-/**
- * Test that changing to all header lines mode displays all the addresses.
- * @param toDescription the description node for the "to" field
- */
-function subtest_change_to_all_header_mode(toDescription) {
- let oldNumLines = help_get_num_lines(toDescription);
-
- change_to_all_header_mode();
- // test that (n more) is gone
- let moreNode = mc.window.document.getElementById("expandedtoBox").more;
- if (!moreNode.collapsed) {
- throw new Error("more node should be collapsed in all header lines mode");
- }
-
- // test that we actually have more lines than we did before!
- let newNumLines = help_get_num_lines(toDescription);
- if (newNumLines <= oldNumLines) {
- throw new Error(
- "number of address lines present in all header lines mode = " +
- newNumLines +
- "<= number of lines present beforehand = " +
- oldNumLines
- );
- }
-}
-
-/**
- * Test that clicking the star updates the UI properly (see bug 563612).
- * @param toDescription the description node for the "to" field
- */
-function subtest_more_widget_star_click(toDescription) {
- let addrs = toDescription.getElementsByTagName("mail-emailaddress");
- let lastAddr = get_last_visible_address(addrs);
- ensure_no_card_exists(lastAddr.getAttribute("emailAddress"));
-
- // scroll to the bottom first so the address is in view
- let view = mc.e("expandedHeaderView");
- view.scrollTop = view.scrollHeight - view.clientHeight;
-
- mc.click(getElement(lastAddr, ".emailStar"));
- if (lastAddr.getAttribute("hascard") == "false") {
- throw new Error("address not updated after clicking star");
- }
-}
-
-/**
- * Make sure the (more) widget hidden pref actually works with a
- * non-default value.
- */
-function test_more_widget_with_maxlines_of_3() {
- // set maxLines to 3
- Services.prefs.setIntPref("mailnews.headers.show_n_lines_before_more", 3);
-
- // call test_more_widget again
- // We need to look at the second last article in the display list.
- test_more_widget();
-}
-
-/**
- * Make sure the (more) widget hidden pref also works with an
- * "all" (0) non-default value.
- */
-function test_more_widget_with_disabled_more() {
- // set maxLines to 0
- Services.prefs.setIntPref("mailnews.headers.show_n_lines_before_more", 0);
-
- // generate message with 35 recips (effectively guarantees overflow for n=3)
- be_in_folder(folder);
- let msg = create_message({ toCount: 35 });
-
- // add the message to the end of the folder
- add_message_to_folder(folder, msg);
-
- // select and open the last message
- let curMessage = select_click_row(-1);
-
- // make sure it loads
- wait_for_message_display_completion(mc);
- assert_selected_and_displayed(mc, curMessage);
-
- // test that (n more) is gone
- let moreNode = mc.window.document.getElementById("expandedtoBox").more;
- if (!moreNode.collapsed) {
- throw new Error("more node should be collapsed in n=0 case");
- }
-
- // get the description element containing the addresses
- let toDescription = mc.window.document.getElementById("expandedtoBox")
- .emailAddresses;
-
- // test that we actually have more lines than the 3 we know are filled
- let newNumLines = help_get_num_lines(toDescription);
- if (newNumLines <= 3) {
- throw new Error(
- "number of address lines present in all addresses mode = " +
- newNumLines +
- "<= number of expected minimum of 3 lines filled"
- );
- }
-}
-
-/**
- * When the window gets too narrow the toolbar should float above the From
- * line. Then they need to return back to the right when we get large
- * enough again.
- */
-function test_toolbar_collapse_and_expand() {
- be_in_folder(folder);
- // Select and open a message, in this case the last, for no particular reason.
- select_click_row(-1);
-
- try {
- let expandedHeadersTopBox = mc.e("expandedHeadersTopBox");
-
- resize_to(mc, 1200, gDefaultWindowHeight);
- let shortHeight = expandedHeadersTopBox.clientHeight;
-
- resize_to(mc, 600, gDefaultWindowHeight);
- let tallHeight = expandedHeadersTopBox.clientHeight;
-
- if (shortHeight >= tallHeight) {
- throw new Error("The header box should have been made smaller!");
- }
-
- // And make our window big to achieve the same effect as the just icons mode.
- resize_to(mc, 1200, gDefaultWindowHeight);
- mc.waitFor(
- () => expandedHeadersTopBox.clientHeight == shortHeight,
- "The header box should have returned to its wide size!"
- );
- } finally {
- // restore window to nominal dimensions
- restore_default_window_size();
- }
-}
-
-/**
- * Test if the tooltip text of the more widget contains the correct addresses
- * not shown in the header and the number of addresses also hidden in the
- * tooltip text.
- * @param aMsg the message for which the subtest should be performed
- */
-function subtest_more_button_tooltip(aMsg) {
- // check for more indicator number of the more widget
- let ccAddrs = MailServices.headerParser.parseEncodedHeader(aMsg.ccList);
- let toAddrs = MailServices.headerParser.parseEncodedHeader(aMsg.recipients);
-
- let shownToAddrNum = get_number_of_addresses_in_header("expandedtoBox");
- let shownCCAddrNum = get_number_of_addresses_in_header("expandedccBox");
-
- // first check the number of addresses in the more widget
- let hiddenCCAddrsNum = ccAddrs.length - shownCCAddrNum;
- let hiddenToAddrsNum = toAddrs.length - shownToAddrNum;
-
- let moreNumberTo = get_number_of_more_button("expandedtoBox");
- assert_not_equals(NaN, moreNumberTo);
- assert_equals(hiddenToAddrsNum, moreNumberTo);
-
- let moreNumberCC = get_number_of_more_button("expandedccBox");
- assert_not_equals(NaN, moreNumberCC);
- assert_equals(hiddenCCAddrsNum, moreNumberCC);
-
- subtest_addresses_in_tooltip_text(
- aMsg.recipients,
- "expandedtoBox",
- shownToAddrNum,
- hiddenToAddrsNum
- );
- subtest_addresses_in_tooltip_text(
- aMsg.ccList,
- "expandedccBox",
- shownCCAddrNum,
- hiddenCCAddrsNum
- );
-}
-
-/**
- * Return the number of addresses visible in headerBox.
- * @param aHeaderBox the id of the header box element for which to look for
- * visible addresses
- * @return the number of visible addresses in the header box
- */
-function get_number_of_addresses_in_header(aHeaderBox) {
- let headerBoxElement = mc.e(aHeaderBox, { class: "headerValue" });
- let addrs = headerBoxElement.getElementsByTagName("mail-emailaddress");
- let addrNum = 0;
- for (let i = 0; i < addrs.length; i++) {
- // check that the address is really visible and not just a cached
- // element
- if (element_visible_recursive(addrs[i])) {
- addrNum += 1;
- }
- }
- return addrNum;
-}
-
-/**
- * Return the number shown in the more widget.
- * @param aHeaderBox the id of the header box element for which to look for
- * the number in the more widget
- * @return the number shown in the more widget
- */
-function get_number_of_more_button(aHeaderBox) {
- let moreNumber = 0;
- let headerBoxElement = mc.e(aHeaderBox);
- let moreIndicator = headerBoxElement.more;
- if (element_visible_recursive(moreIndicator)) {
- let moreText = moreIndicator.getAttribute("value");
- let moreSplit = moreText.split(" ");
- moreNumber = parseInt(moreSplit[0]);
- }
- return moreNumber;
-}
-
-/**
- * Check if hidden addresses are part of more tooltip text.
- * @param aRecipients an array containing the addresses to look for in the
- * header or the tooltip text
- * @param aHeaderBox the id of the header box element for which to look
- * for hidden addresses
- * @param aShownAddrsNum the number of addresses shown in the header
- * @param aHiddenAddrsNum the number of addresses not shown in the header
- */
-function subtest_addresses_in_tooltip_text(
- aRecipients,
- aHeaderBox,
- aShownAddrsNum,
- aHiddenAddrsNum
-) {
- // check for more indicator number of the more widget
- let addresses = MailServices.headerParser.parseEncodedHeader(aRecipients);
-
- let headerBoxElement = mc.e(aHeaderBox);
- let moreIndicator = headerBoxElement.more;
- let tooltipText = moreIndicator.getAttribute("tooltiptext");
- let maxTooltipAddrsNum = headerBoxElement.maxAddressesInMoreTooltipValue;
- let addrsNumInTooltip = 0;
-
- for (
- let i = aShownAddrsNum;
- i < addresses.length && i < maxTooltipAddrsNum + aShownAddrsNum;
- i++
- ) {
- assert_true(
- tooltipText.includes(addresses[i].toString()),
- addresses[i].toString()
- );
- addrsNumInTooltip += 1;
- }
-
- if (aHiddenAddrsNum < maxTooltipAddrsNum) {
- assert_equals(aHiddenAddrsNum, addrsNumInTooltip);
- } else {
- assert_equals(maxTooltipAddrsNum, addrsNumInTooltip);
- // check if ", and X more" shows the correct number
- let moreTooltipSplit = tooltipText.split(", ");
- let words = mc.window.document
- .getElementById("bundle_messenger")
- .getString("headerMoreAddrsTooltip");
- let remainingAddresses =
- addresses.length - aShownAddrsNum - maxTooltipAddrsNum;
- let moreForm = mc.window.PluralForm.get(remainingAddresses, words).replace(
- "#1",
- remainingAddresses
- );
- assert_equals(
- moreForm,
- ", " + moreTooltipSplit[moreTooltipSplit.length - 1]
- );
- }
-}
deleted file mode 100644
--- a/mail/test/mozmill/message-header/test-phishing-bar.js
+++ /dev/null
@@ -1,256 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Test that phishing notifications behave properly.
- */
-
-"use strict";
-
-var os = ChromeUtils.import("chrome://mozmill/content/stdlib/os.jsm");
-
-var { gMockExtProtSvcReg } = ChromeUtils.import(
- "resource://testing-common/mozmill/ContentTabHelpers.jsm"
-);
-var {
- add_message_to_folder,
- be_in_folder,
- create_folder,
- create_message,
- mc,
- open_message_from_file,
- select_click_row,
- wait_for_message_display_completion,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var {
- assert_notification_displayed,
- get_notification_button,
- wait_for_notification_to_show,
- wait_for_notification_to_stop,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/NotificationBoxHelpers.jsm"
-);
-var {
- close_window,
- plan_for_modal_dialog,
- plan_for_new_window,
- wait_for_new_window,
-} = ChromeUtils.import("resource://testing-common/mozmill/WindowHelpers.jsm");
-
-var folder;
-
-var kBoxId = "mail-notification-top";
-var kNotificationValue = "maybeScam";
-
-function setupModule(module) {
- gMockExtProtSvcReg.register();
-
- folder = create_folder("PhishingBarA");
- add_message_to_folder(
- folder,
- create_message({
- body: {
- body: '<form action="http://localhost/download-me"><input></form>.',
- contentType: "text/html",
- },
- })
- );
- add_message_to_folder(folder, create_message());
- add_message_to_folder(
- folder,
- create_message({
- body: {
- body: "check out http://130.128.4.1. and http://130.128.4.2/.",
- contentType: "text/plain",
- },
- })
- );
- add_message_to_folder(
- folder,
- create_message({
- body: {
- body:
- '<a href="http://subdomain.google.com/">http://www.google.com</a>.',
- contentType: "text/html",
- },
- })
- );
- add_message_to_folder(
- folder,
- create_message({
- body: {
- body: '<a href="http://subdomain.google.com/">http://google.com</a>.',
- contentType: "text/html",
- },
- })
- );
- add_message_to_folder(
- folder,
- create_message({
- body: {
- body: '<a href="http://evilhost">http://localhost</a>.',
- contentType: "text/html",
- },
- })
- );
- add_message_to_folder(
- folder,
- create_message({
- body: {
- body: '<form action="http://localhost/download-me"><input></form>.',
- contentType: "text/html",
- },
- })
- );
-}
-
-function teardownModule() {
- gMockExtProtSvcReg.unregister();
-}
-
-/**
- * Make sure the notification shows, and goes away once the Ignore menuitem
- * is clicked.
- */
-function assert_ignore_works(aController) {
- wait_for_notification_to_show(aController, kBoxId, kNotificationValue);
- let prefButton = get_notification_button(
- aController,
- kBoxId,
- kNotificationValue,
- { popup: "phishingOptions" }
- );
- aController.click(new elementslib.Elem(prefButton));
- aController.click_menus_in_sequence(aController.e("phishingOptions"), [
- { id: "phishingOptionIgnore" },
- ]);
- wait_for_notification_to_stop(aController, kBoxId, kNotificationValue);
-}
-
-/**
- * Helper function to click the first link in a message if one is available.
- */
-function click_link_if_available() {
- let msgBody = mc.e("messagepane").contentDocument.body;
- if (msgBody.getElementsByTagName("a").length > 0) {
- msgBody.getElementsByTagName("a")[0].click();
- }
-}
-
-/**
- * Test that when viewing a message, choosing ignore hides the the phishing
- * notification.
- */
-function test_ignore_phishing_warning_from_message() {
- be_in_folder(folder);
- select_click_row(0);
- assert_ignore_works(mc);
-
- select_click_row(1);
- // msg 1 is normal -> no phishing warning
- assert_notification_displayed(mc, kBoxId, kNotificationValue, false);
- select_click_row(0);
- // msg 0 is a potential phishing attempt, but we ignored it so that should
- // be remembered
- assert_notification_displayed(mc, kBoxId, kNotificationValue, false);
-}
-
-/**
- * Test that when viewing en eml file, choosing ignore hides the phishing
- * notification.
- */
-function test_ignore_phishing_warning_from_eml() {
- let thisFilePath = os.getFileForPath(__file__);
- let file = os.getFileForPath(os.abspath("./evil.eml", thisFilePath));
-
- let msgc = open_message_from_file(file);
- assert_ignore_works(msgc);
- close_window(msgc);
-}
-
-/**
- * Test that when viewing an attached eml file, the phishing notification works.
- */
-function test_ignore_phishing_warning_from_eml_attachment() {
- let thisFilePath = os.getFileForPath(__file__);
- let file = os.getFileForPath(os.abspath("./evil-attached.eml", thisFilePath));
-
- let msgc = open_message_from_file(file);
-
- // Make sure the root message shows the phishing bar.
- wait_for_notification_to_show(msgc, kBoxId, kNotificationValue);
-
- // Open the attached message.
- plan_for_new_window("mail:messageWindow");
- msgc
- .e("attachmentList")
- .getItemAtIndex(0)
- .attachment.open();
- let msgc2 = wait_for_new_window("mail:messageWindow");
- wait_for_message_display_completion(msgc2, true);
-
- // Now make sure the attached message shows the phishing bar.
- wait_for_notification_to_show(msgc2, kBoxId, kNotificationValue);
-
- close_window(msgc2);
- close_window(msgc);
-}
-
-/**
- * Test that when viewing a message with an auto-linked ip address, we don't
- * get a warning when clicking the link.
- * We'll have http://130.128.4.1 vs. http://130.128.4.1/
- */
-function test_no_phishing_warning_for_ip_sameish_text() {
- be_in_folder(folder);
- select_click_row(2); // Mail with Public IP address.
- click_link_if_available();
- assert_notification_displayed(mc, kBoxId, kNotificationValue, false); // not shown
-}
-
-/**
- * Test that when viewing a message with a link whose base domain matches but
- * has a different subdomain (e.g. http://subdomain.google.com/ vs
- * http://google.com/), we don't get a warning if the link is pressed.
- */
-function test_no_phishing_warning_for_subdomain() {
- be_in_folder(folder);
- select_click_row(3);
- click_link_if_available();
- assert_notification_displayed(mc, kBoxId, kNotificationValue, false); // not shown
-
- select_click_row(4);
- click_link_if_available();
- assert_notification_displayed(mc, kBoxId, kNotificationValue, false); // not shown
-}
-
-/**
- * Test that when clicking a link where the text and/or href
- * has no TLD, we still warn as appropriate.
- */
-function test_phishing_warning_for_local_domain() {
- be_in_folder(folder);
- select_click_row(5);
-
- let dialogAppeared = false;
-
- plan_for_modal_dialog("commonDialogWindow", function(ctrler) {
- dialogAppeared = true;
- });
-
- click_link_if_available();
-
- return dialogAppeared;
-}
-
-/**
- * Test that we warn about emails which contain <form>s with action attributes.
- */
-function test_phishing_warning_for_action_form() {
- be_in_folder(folder);
- select_click_row(6);
- assert_notification_displayed(mc, kBoxId, kNotificationValue, true); // shown
-}
deleted file mode 100644
--- a/mail/test/mozmill/message-header/test-reply-identity.js
+++ /dev/null
@@ -1,225 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests that actions such as replying choses the most suitable identity.
- */
-
-"use strict";
-
-var { close_compose_window, open_compose_with_reply } = ChromeUtils.import(
- "resource://testing-common/mozmill/ComposeHelpers.jsm"
-);
-var {
- add_message_to_folder,
- assert_selected_and_displayed,
- be_in_folder,
- create_message,
- mc,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-var testFolder = null;
-
-var identity1Email = "carl@example.com";
-var identity2Email = "lenny@springfield.invalid";
-
-function setupModule(module) {
- addIdentitiesAndFolder();
- // Msg #0
- add_message_to_folder(
- testFolder,
- create_message({
- from: "Homer <homer@example.com>",
- to: "workers@springfield.invalid",
- subject: "no matching identity, like bcc/list",
- body: {
- body:
- "Alcohol is a way of life, alcohol is my way of life, and I aim to keep it.",
- },
- clobberHeaders: {},
- })
- );
- // Msg #1
- add_message_to_folder(
- testFolder,
- create_message({
- from: "Homer <homer@example.com>",
- to: "powerplant-workers@springfield.invalid",
- subject: "only delivered-to header matching identity",
- body: {
- body: "Just because I don't care doesn't mean I don't understand.",
- },
- clobberHeaders: {
- "Delivered-To": "<" + identity2Email + ">",
- },
- })
- );
- // Msg #2
- add_message_to_folder(
- testFolder,
- create_message({
- from: "Homer <homer@example.com>",
- to: "powerplant-workers@springfield.invalid, Apu <apu@test.invalid>",
- cc: "other." + identity2Email,
- subject: "subpart of cc address matching identity",
- body: { body: "Blame the guy who doesn't speak Engish." },
- clobberHeaders: {},
- })
- );
- // Msg #3
- add_message_to_folder(
- testFolder,
- create_message({
- from: "Homer <homer@example.com>",
- to: "Lenny <" + identity2Email + ">",
- subject: "normal to:address match, with full name",
- body: {
- body: "Remember as far as anyone knows, we're a nice normal family.",
- },
- })
- );
- // Msg #4
- add_message_to_folder(
- testFolder,
- create_message({
- from: "Homer <homer@example.com>",
- to: "powerplant-workers@springfield.invalid",
- subject: "delivered-to header matching only subpart of identity email",
- body: { body: "Mmmm...Forbidden donut" },
- clobberHeaders: {
- "Delivered-To": "<other." + identity2Email + ">",
- },
- })
- );
- // Msg #5
- add_message_to_folder(
- testFolder,
- create_message({
- from: identity2Email + " <" + identity2Email + ">",
- to: "Marge <marge@example.com>",
- subject: "from second self",
- body: {
- body: "All my life I've had one dream, to achieve my many goals.",
- },
- })
- );
-}
-
-function addIdentitiesAndFolder() {
- let server = MailServices.accounts.createIncomingServer(
- "nobody",
- "Reply Identity Testing",
- "pop3"
- );
- testFolder = server.rootFolder
- .QueryInterface(Ci.nsIMsgLocalMailFolder)
- .createLocalSubfolder("Replies");
-
- let identity = MailServices.accounts.createIdentity();
- identity.email = identity1Email;
-
- let identity2 = MailServices.accounts.createIdentity();
- identity2.email = identity2Email;
-
- let account = MailServices.accounts.createAccount();
- account.incomingServer = server;
- account.addIdentity(identity);
- account.addIdentity(identity2);
-}
-
-function checkReply(replyWin, expectedFromEmail) {
- let identityList = replyWin.e("msgIdentity");
- if (!identityList.selectedItem.label.includes(expectedFromEmail)) {
- throw new Error(
- "The From address is not correctly selected! Expected: " +
- expectedFromEmail +
- "; Actual: " +
- identityList.selectedItem.label
- );
- }
-}
-
-function test_reply_no_matching_identity() {
- be_in_folder(testFolder);
-
- let msg = select_click_row(0);
- assert_selected_and_displayed(mc, msg);
-
- let replyWin = open_compose_with_reply();
- // Should have selected the default identity.
- checkReply(replyWin, identity1Email);
- close_compose_window(replyWin);
-}
-
-function test_reply_matching_only_deliveredto() {
- be_in_folder(testFolder);
-
- let msg = select_click_row(1);
- assert_selected_and_displayed(mc, msg);
-
- let replyWin = open_compose_with_reply();
- // Should have selected the second id, which is listed in Delivered-To:.
- checkReply(replyWin, identity2Email);
- close_compose_window(replyWin, false /* no prompt*/);
-}
-
-function test_reply_matching_subaddress() {
- be_in_folder(testFolder);
-
- let msg = select_click_row(2);
- assert_selected_and_displayed(mc, msg);
-
- let replyWin = open_compose_with_reply();
- // Should have selected the first id, the email doesn't fully match.
- // other.lenny != "our" lenny
- checkReply(replyWin, identity1Email);
- close_compose_window(replyWin);
-}
-
-function test_reply_to_matching_second_id() {
- be_in_folder(testFolder);
-
- let msg = select_click_row(3);
- assert_selected_and_displayed(mc, msg);
-
- let replyWin = open_compose_with_reply();
- // Should have selected the second id, which was in To;.
- checkReply(replyWin, identity2Email);
- close_compose_window(replyWin);
-}
-
-function test_deliveredto_to_matching_only_parlty() {
- be_in_folder(testFolder);
-
- let msg = select_click_row(4);
- assert_selected_and_displayed(mc, msg);
-
- let replyWin = open_compose_with_reply();
- // Should have selected the (default) first id.
- checkReply(replyWin, identity1Email);
- close_compose_window(replyWin);
-}
-
-/**
- * A reply from self is treated as a follow-up. And this self
- * was the second identity, so the reply should also be from the second identity.
- */
-function test_reply_to_self_second_id() {
- be_in_folder(testFolder);
-
- let msg = select_click_row(5);
- assert_selected_and_displayed(mc, msg);
-
- let replyWin = open_compose_with_reply();
- // Should have selected the second id, which was in From.
- checkReply(replyWin, identity2Email);
- close_compose_window(replyWin, false /* no prompt*/);
-}
deleted file mode 100644
--- a/mail/test/mozmill/message-header/test-reply-to-list-from-address-selection.js
+++ /dev/null
@@ -1,119 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test for the most suitable identity in From address for reply-to-list
- */
-
-"use strict";
-
-var { open_compose_with_reply_to_list } = ChromeUtils.import(
- "resource://testing-common/mozmill/ComposeHelpers.jsm"
-);
-var {
- assert_selected_and_displayed,
- be_in_folder,
- mc,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-var testFolder = null;
-var msgHdr = null;
-var replyToListWindow = null;
-
-var identityString1 = "tinderbox_correct_identity@foo.invalid";
-
-function setupModule(module) {
- addIdentitiesAndFolder();
- addMessageToFolder(testFolder);
-}
-
-function addMessageToFolder(aFolder) {
- var msgId =
- Cc["@mozilla.org/uuid-generator;1"]
- .getService(Ci.nsIUUIDGenerator)
- .generateUUID() + "@mozillamessaging.invalid";
-
- var source =
- "From - Sat Nov 1 12:39:54 2008\n" +
- "X-Mozilla-Status: 0001\n" +
- "X-Mozilla-Status2: 00000000\n" +
- "Delivered-To: <tinderbox_identity333@foo.invalid>\n" +
- "Delivered-To: <" +
- identityString1 +
- ">\n" +
- "Delivered-To: <tinderbox_identity555@foo.invalid>\n" +
- "Message-ID: <" +
- msgId +
- ">\n" +
- "Date: Wed, 11 Jun 2008 20:32:02 -0400\n" +
- "From: Tester <tests@mozillamessaging.invalid>\n" +
- "User-Agent: Thunderbird 3.0a2pre (Macintosh/2008052122)\n" +
- "MIME-Version: 1.0\n" +
- "List-ID: <list.mozillamessaging.invalid>\n" +
- "List-Post: <list.mozillamessaging.invalid>, \n" +
- " <mailto: list@mozillamessaging.invalid>\n" +
- "To: recipient@mozillamessaging.invalid\n" +
- "Subject: a subject\n" +
- "Content-Type: text/html; charset=ISO-8859-1\n" +
- "Content-Transfer-Encoding: 7bit\n" +
- "\ntext body\n";
-
- aFolder.QueryInterface(Ci.nsIMsgLocalMailFolder);
- aFolder.gettingNewMessages = true;
- aFolder.addMessage(source);
- aFolder.gettingNewMessages = false;
-
- return aFolder.msgDatabase.getMsgHdrForMessageID(msgId);
-}
-
-function addIdentitiesAndFolder() {
- let identity2 = MailServices.accounts.createIdentity();
- // identity.fullName = "Tinderbox_Identity1";
- identity2.email = "tinderbox_identity1@foo.invalid";
-
- let identity = MailServices.accounts.createIdentity();
- // identity.fullName = "Tinderbox_Identity1";
- identity.email = identityString1;
-
- let server = MailServices.accounts.createIncomingServer(
- "nobody",
- "Test Local Folders",
- "pop3"
- );
- let localRoot = server.rootFolder.QueryInterface(Ci.nsIMsgLocalMailFolder);
- testFolder = localRoot.createLocalSubfolder("Test Folder");
-
- let account = MailServices.accounts.createAccount();
- account.incomingServer = server;
- account.addIdentity(identity);
- account.addIdentity(identity2);
-}
-
-function test_Reply_To_List_From_Address() {
- be_in_folder(testFolder);
-
- let curMessage = select_click_row(0);
- assert_selected_and_displayed(mc, curMessage);
-
- replyToListWindow = open_compose_with_reply_to_list();
-
- var identityList = replyToListWindow.e("msgIdentity");
-
- // see if it's the correct identity selected
- if (!identityList.selectedItem.label.includes(identityString1)) {
- throw new Error(
- "The From address is not correctly selected! Expected: " +
- identityString1 +
- "; Actual: " +
- identityList.selectedItem.label
- );
- }
-}
deleted file mode 100644
--- a/mail/test/mozmill/message-header/test-return-receipt.js
+++ /dev/null
@@ -1,193 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test return receipt (MDN) stuff.
- */
-
-"use strict";
-
-var {
- add_message_to_folder,
- assert_selected_and_displayed,
- be_in_folder,
- create_folder,
- create_message,
- mc,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { assert_notification_displayed } = ChromeUtils.import(
- "resource://testing-common/mozmill/NotificationBoxHelpers.jsm"
-);
-
-var folder;
-
-var kBoxId = "mail-notification-top";
-var kNotificationValue = "mdnRequested";
-
-function setupModule(module) {
- folder = create_folder("ReturnReceiptTest");
-
- // Create a message that requests a return receipt.
- let msg0 = create_message({
- from: ["Ake", "ake@example.com"],
- clobberHeaders: { "Disposition-Notification-To": "ake@example.com" },
- });
- add_message_to_folder(folder, msg0);
-
- // ... and one that doesn't request a return receipt.
- let msg1 = create_message();
- add_message_to_folder(folder, msg1);
-
- // Create a message that requests a return receipt to a different address.
- let msg2 = create_message({
- from: ["Mimi", "me@example.org"],
- clobberHeaders: { "Disposition-Notification-To": "other@example.com" },
- });
- add_message_to_folder(folder, msg2);
-
- // Create a message that requests a return receipt to different addresses.
- let msg3 = create_message({
- from: ["Bobby", "bob@example.org"],
- clobberHeaders: {
- "Disposition-Notification-To": "ex1@example.com, ex2@example.com",
- },
- });
- add_message_to_folder(folder, msg3);
-
- // Create a message that requests a return receipt using non-standard header.
- let msg4 = create_message({
- from: ["Ake", "ake@example.com"],
- clobberHeaders: { "Return-Receipt-To": "ake@example.com" },
- });
- add_message_to_folder(folder, msg4);
-
- // Create a message that requests a return receipt to a different address
- // using non-standard header.
- let msg5 = create_message({
- from: ["Mimi", "me@example.org"],
- clobberHeaders: { "Return-Receipt-To": "other@example.com" },
- });
- add_message_to_folder(folder, msg5);
-
- // Create a message that requests a return receipt to different addresses
- // using non-standard header.
- let msg6 = create_message({
- from: ["Bobby", "bob@example.org"],
- clobberHeaders: { "Return-Receipt-To": "ex1@example.com, ex2@example.com" },
- });
- add_message_to_folder(folder, msg6);
-}
-
-/** Utility to select a message. */
-function gotoMsg(row) {
- be_in_folder(folder);
- let curMessage = select_click_row(row);
- assert_selected_and_displayed(mc, curMessage);
-}
-
-/**
- * Utility to make sure the MDN bar is shown / not shown.
- */
-function assert_mdn_shown(shouldShow) {
- assert_notification_displayed(mc, kBoxId, kNotificationValue, shouldShow);
-}
-
-/**
- * Utility function to make sure the notification contains a certain text.
- */
-function assert_mdn_text_contains(text, shouldContain) {
- let nb = mc.window.document.getElementById(kBoxId);
- let box = nb.querySelector(".notificationbox-stack")._notificationBox;
- let notificationText = box.currentNotification.messageText.textContent;
- if (shouldContain && !notificationText.includes(text)) {
- throw new Error(
- "mdnBar should contain text=" +
- text +
- "; notificationText=" +
- notificationText
- );
- }
- if (!shouldContain && notificationText.includes(text)) {
- throw new Error(
- "mdnBar shouldn't contain text=" +
- text +
- "; notificationText=" +
- notificationText
- );
- }
-}
-
-/**
- * Test that return receipts are not shown when Disposition-Notification-To
- * and Return-Receipt-To isn't set.
- */
-function test_no_mdn_for_normal_msgs() {
- gotoMsg(1); // This message doesn't request a return receipt.
- assert_mdn_shown(false);
-}
-
-/**
- * Test that return receipts are shown when Disposition-Notification-To is set.
- */
-function test_basic_mdn_shown() {
- gotoMsg(0); // This message requests a return receipt.
- assert_mdn_shown(true);
- assert_mdn_text_contains("ake@example.com", false); // only name should show
-}
-
-/**
- * Test that return receipts are shown when Return-Receipt-To is set.
- */
-function test_basic_mdn_shown_nonrfc() {
- gotoMsg(4); // This message requests a return receipt.
- assert_mdn_shown(true);
- assert_mdn_text_contains("ake@example.com", false); // only name should show
-}
-
-/**
- * Test that return receipts warns when the mdn address is different.
- * The RFC compliant version.
- */
-function test_mdn_when_from_and_disposition_to_differs() {
- gotoMsg(2); // Should display a notification with warning.
- assert_mdn_shown(true);
- assert_mdn_text_contains("other@example.com", true); // address should show
-}
-
-/**
- * Test that return receipts warns when the mdn address is different.
- * The RFC non-compliant version.
- */
-function test_mdn_when_from_and_disposition_to_differs_nonrfc() {
- gotoMsg(5); // Should display a notification with warning.
- assert_mdn_shown(true);
- assert_mdn_text_contains("other@example.com", true); // address should show
-}
-
-/**
- * Test that return receipts warns when the mdn address consists of multiple
- * addresses.
- */
-function test_mdn_when_disposition_to_multi() {
- gotoMsg(3);
- // Should display a notification with warning listing all the addresses.
- assert_mdn_shown(true);
- assert_mdn_text_contains("ex1@example.com", true);
- assert_mdn_text_contains("ex2@example.com", true);
-}
-
-/**
- * Test that return receipts warns when the mdn address consists of multiple
- * addresses. Non-RFC compliant version.
- */
-function test_mdn_when_disposition_to_multi_nonrfc() {
- gotoMsg(6);
- // Should display a notification with warning listing all the addresses.
- assert_mdn_shown(true);
- assert_mdn_text_contains("ex1@example.com", true);
- assert_mdn_text_contains("ex2@example.com", true);
-}
deleted file mode 100644
--- a/mail/test/mozmill/message-reader/bug594646_newline_charset_8bit.eml
+++ /dev/null
@@ -1,23 +0,0 @@
-X-Identity-Key: id1
-X-Account-Key: account2
-Date: Tue, 18 Dec 2012 13:42:01 +0100
-X-Mozilla-Draft-Info: internal/draft; vcard=0; receipt=0; DSN=0; uuencode=0
-User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:19.0) Gecko/20121217 Thunderbird/19.0a2
-MIME-Version: 1.0
-Subject: html test
-X-Enigmail-Version: 1.5a1pre
-Content-Type: text/html; charset=ISO-8859-2
-Content-Transfer-Encoding: 8bit
-
-<html>
- <head>
- <meta http-equiv="content-type" content="text/html;
- charset=ISO-8859-2">
- </head>
- <body bgcolor="#FFFFFF" text="#000000">
- <tt>árvíztûrõ tükörfúrógép<br>
- ÁRVÍZTÛRÕ TÜKÖRFÚRÓGÉP<br>
- <br>
- </tt>
- </body>
-</html>
deleted file mode 100644
--- a/mail/test/mozmill/message-reader/bug594646_newline_charset_b64.eml
+++ /dev/null
@@ -1,16 +0,0 @@
-X-Identity-Key: id1
-X-Account-Key: account2
-Date: Tue, 18 Dec 2012 13:42:01 +0100
-X-Mozilla-Draft-Info: internal/draft; vcard=0; receipt=0; DSN=0; uuencode=0
-User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:19.0) Gecko/20121217 Thunderbird/19.0a2
-MIME-Version: 1.0
-Subject: html test
-X-Enigmail-Version: 1.5a1pre
-Content-Type: text/html; charset=ISO-8859-2
-Content-Transfer-Encoding: base64
-
-PGh0bWw+CiAgPGhlYWQ+CiAgICA8bWV0YSBodHRwLWVxdWl2PSJjb250ZW50LXR5cGUiIGNvbnRl
-bnQ9InRleHQvaHRtbDsKICAgICAgY2hhcnNldD1JU08tODg1OS0yIj4KICA8L2hlYWQ+CiAgPGJv
-ZHkgYmdjb2xvcj0iI0ZGRkZGRiIgdGV4dD0iIzAwMDAwMCI+CiAgICA8dHQ+4XJ27Xp0+3L1IHT8
-a/ZyZvpy82fpcDxicj4KICAgICAgwVJWzVpU21LVIFTcS9ZSRtpS00fJUDxicj4KICAgICAgPGJy
-PgogICAgPC90dD4KICA8L2JvZHk+CjwvaHRtbD4K
deleted file mode 100644
--- a/mail/test/mozmill/message-reader/bug594646_newline_charset_qp.eml
+++ /dev/null
@@ -1,23 +0,0 @@
-X-Identity-Key: id1
-X-Account-Key: account2
-Date: Tue, 18 Dec 2012 13:42:01 +0100
-X-Mozilla-Draft-Info: internal/draft; vcard=0; receipt=0; DSN=0; uuencode=0
-User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:19.0) Gecko/20121217 Thunderbird/19.0a2
-MIME-Version: 1.0
-Subject: html test
-X-Enigmail-Version: 1.5a1pre
-Content-Type: text/html; charset=ISO-8859-2
-Content-Transfer-Encoding: quoted-printable
-
-<html>
- <head>
- <meta http-equiv=3D"content-type" content=3D"text/html;=
- charset=3DISO-8859-2">
- </head>
- <body bgcolor=3D"#FFFFFF" text=3D"#000000">
- <tt>=E1rv=EDzt=FBr=F5 t=FCk=F6rf=FAr=F3g=E9p<br>
- =C1RV=CDZT=DBR=D5 T=DCK=D6RF=DAR=D3G=C9P<br>
- <br>
- </tt>
- </body>
-</html>
deleted file mode 100644
--- a/mail/test/mozmill/message-reader/bug594646_newline_httpequiv_8bit.eml
+++ /dev/null
@@ -1,23 +0,0 @@
-X-Identity-Key: id1
-X-Account-Key: account2
-Date: Tue, 18 Dec 2012 13:42:01 +0100
-X-Mozilla-Draft-Info: internal/draft; vcard=0; receipt=0; DSN=0; uuencode=0
-User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:19.0) Gecko/20121217 Thunderbird/19.0a2
-MIME-Version: 1.0
-Subject: html test
-X-Enigmail-Version: 1.5a1pre
-Content-Type: text/html; charset=ISO-8859-2
-Content-Transfer-Encoding: 8bit
-
-<html>
- <head>
- <meta content="text/html; charset=ISO-8859-2"
- http-equiv="content-type">
- </head>
- <body bgcolor="#FFFFFF" text="#000000">
- <tt>árvíztûrõ tükörfúrógép<br>
- ÁRVÍZTÛRÕ TÜKÖRFÚRÓGÉP<br>
- <br>
- </tt>
- </body>
-</html>
deleted file mode 100644
--- a/mail/test/mozmill/message-reader/bug594646_newline_httpequiv_b64.eml
+++ /dev/null
@@ -1,16 +0,0 @@
-X-Identity-Key: id1
-X-Account-Key: account2
-Date: Tue, 18 Dec 2012 13:42:01 +0100
-X-Mozilla-Draft-Info: internal/draft; vcard=0; receipt=0; DSN=0; uuencode=0
-User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:19.0) Gecko/20121217 Thunderbird/19.0a2
-MIME-Version: 1.0
-Subject: html test
-X-Enigmail-Version: 1.5a1pre
-Content-Type: text/html; charset=ISO-8859-2
-Content-Transfer-Encoding: base64
-
-PGh0bWw+CiAgPGhlYWQ+CiAgICA8bWV0YSBjb250ZW50PSJ0ZXh0L2h0bWw7IGNoYXJzZXQ9SVNP
-LTg4NTktMiIKICAgICAgaHR0cC1lcXVpdj0iY29udGVudC10eXBlIj4KICA8L2hlYWQ+CiAgPGJv
-ZHkgYmdjb2xvcj0iI0ZGRkZGRiIgdGV4dD0iIzAwMDAwMCI+CiAgICA8dHQ+4XJ27Xp0+3L1IHT8
-a/ZyZvpy82fpcDxicj4KICAgICAgwVJWzVpU21LVIFTcS9ZSRtpS00fJUDxicj4KICAgICAgPGJy
-PgogICAgPC90dD4KICA8L2JvZHk+CjwvaHRtbD4K
deleted file mode 100644
--- a/mail/test/mozmill/message-reader/bug594646_newline_httpequiv_qp.eml
+++ /dev/null
@@ -1,23 +0,0 @@
-X-Identity-Key: id1
-X-Account-Key: account2
-Date: Tue, 18 Dec 2012 13:42:01 +0100
-X-Mozilla-Draft-Info: internal/draft; vcard=0; receipt=0; DSN=0; uuencode=0
-User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:19.0) Gecko/20121217 Thunderbird/19.0a2
-MIME-Version: 1.0
-Subject: html test
-X-Enigmail-Version: 1.5a1pre
-Content-Type: text/html; charset=ISO-8859-2
-Content-Transfer-Encoding: quoted-printable
-
-<html>
- <head>
- <meta content=3D"text/html; charset=3DISO-8859-2"=
- http-equiv=3D"content-type">
- </head>
- <body bgcolor=3D"#FFFFFF" text=3D"#000000">
- <tt>=E1rv=EDzt=FBr=F5 t=FCk=F6rf=FAr=F3g=E9p<br>
- =C1RV=CDZT=DBR=D5 T=DCK=D6RF=DAR=D3G=C9P<br>
- <br>
- </tt>
- </body>
-</html>
deleted file mode 100644
--- a/mail/test/mozmill/message-reader/bug594646_reference.eml
+++ /dev/null
@@ -1,22 +0,0 @@
-X-Identity-Key: id1
-X-Account-Key: account2
-Date: Tue, 18 Dec 2012 13:42:01 +0100
-X-Mozilla-Draft-Info: internal/draft; vcard=0; receipt=0; DSN=0; uuencode=0
-User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:19.0) Gecko/20121217 Thunderbird/19.0a2
-MIME-Version: 1.0
-Subject: html test
-X-Enigmail-Version: 1.5a1pre
-Content-Type: text/html; charset=ISO-8859-2
-Content-Transfer-Encoding: quoted-printable
-
-<html>
- <head>
- <meta http-equiv=3D"content-type" content=3D"text/html; charset=3DISO-8859-2">
- </head>
- <body bgcolor=3D"#FFFFFF" text=3D"#000000">
- <tt>=E1rv=EDzt=FBr=F5 t=FCk=F6rf=FAr=F3g=E9p<br>
- =C1RV=CDZT=DBR=D5 T=DCK=D6RF=DAR=D3G=C9P<br>
- <br>
- </tt>
- </body>
-</html>
deleted file mode 100644
--- a/mail/test/mozmill/message-reader/bug594646_reversed_order_8bit.eml
+++ /dev/null
@@ -1,22 +0,0 @@
-X-Identity-Key: id1
-X-Account-Key: account2
-Date: Tue, 18 Dec 2012 13:42:01 +0100
-X-Mozilla-Draft-Info: internal/draft; vcard=0; receipt=0; DSN=0; uuencode=0
-User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:19.0) Gecko/20121217 Thunderbird/19.0a2
-MIME-Version: 1.0
-Subject: html test
-X-Enigmail-Version: 1.5a1pre
-Content-Type: text/html; charset=ISO-8859-2
-Content-Transfer-Encoding: 8bit
-
-<html>
- <head>
- <meta content="text/html; charset=ISO-8859-2" http-equiv="content-type">
- </head>
- <body bgcolor="#FFFFFF" text="#000000">
- <tt>árvíztûrõ tükörfúrógép<br>
- ÁRVÍZTÛRÕ TÜKÖRFÚRÓGÉP<br>
- <br>
- </tt>
- </body>
-</html>
deleted file mode 100644
--- a/mail/test/mozmill/message-reader/bug594646_reversed_order_b64.eml
+++ /dev/null
@@ -1,16 +0,0 @@
-X-Identity-Key: id1
-X-Account-Key: account2
-Date: Tue, 18 Dec 2012 13:42:01 +0100
-X-Mozilla-Draft-Info: internal/draft; vcard=0; receipt=0; DSN=0; uuencode=0
-User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:19.0) Gecko/20121217 Thunderbird/19.0a2
-MIME-Version: 1.0
-Subject: html test
-X-Enigmail-Version: 1.5a1pre
-Content-Type: text/html; charset=ISO-8859-2
-Content-Transfer-Encoding: base64
-
-PGh0bWw+CiAgPGhlYWQ+CiAgICA8bWV0YSBjb250ZW50PSJ0ZXh0L2h0bWw7IGNoYXJzZXQ9SVNP
-LTg4NTktMiIgaHR0cC1lcXVpdj0iY29udGVudC10eXBlIj4KICA8L2hlYWQ+CiAgPGJvZHkgYmdj
-b2xvcj0iI0ZGRkZGRiIgdGV4dD0iIzAwMDAwMCI+CiAgICA8dHQ+4XJ27Xp0+3L1IHT8a/ZyZvpy
-82fpcDxicj4KICAgICAgwVJWzVpU21LVIFTcS9ZSRtpS00fJUDxicj4KICAgICAgPGJyPgogICAg
-PC90dD4KICA8L2JvZHk+CjwvaHRtbD4K
deleted file mode 100644
--- a/mail/test/mozmill/message-reader/bug594646_reversed_order_qp.eml
+++ /dev/null
@@ -1,22 +0,0 @@
-X-Identity-Key: id1
-X-Account-Key: account2
-Date: Tue, 18 Dec 2012 13:42:01 +0100
-X-Mozilla-Draft-Info: internal/draft; vcard=0; receipt=0; DSN=0; uuencode=0
-User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:19.0) Gecko/20121217 Thunderbird/19.0a2
-MIME-Version: 1.0
-Subject: html test
-X-Enigmail-Version: 1.5a1pre
-Content-Type: text/html; charset=ISO-8859-2
-Content-Transfer-Encoding: quoted-printable
-
-<html>
- <head>
- <meta content=3D"text/html; charset=3DISO-8859-2" http-equiv=3D"content-type">
- </head>
- <body bgcolor=3D"#FFFFFF" text=3D"#000000">
- <tt>=E1rv=EDzt=FBr=F5 t=FCk=F6rf=FAr=F3g=E9p<br>
- =C1RV=CDZT=DBR=D5 T=DCK=D6RF=DAR=D3G=C9P<br>
- <br>
- </tt>
- </body>
-</html>
deleted file mode 100644
--- a/mail/test/mozmill/message-reader/test-bug594646.js
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-/**
- * Tests that opening an .eml file the body of the message is correct,
- * that it hasn't been UTF-8 mojibake'd.
- */
-
-"use strict";
-
-var os = ChromeUtils.import("chrome://mozmill/content/stdlib/os.jsm");
-
-var { assert_equals, open_message_from_file } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { close_window } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var gReferenceTextContent;
-
-function setupModule(module) {
- gReferenceTextContent = extract_eml_body_textcontent(
- "./bug594646_reference.eml"
- );
-}
-
-function extract_eml_body_textcontent(eml) {
- let file = os.getFileForPath(os.abspath(eml, os.getFileForPath(__file__)));
- let msgc = open_message_from_file(file);
-
- // Be sure to view message body as Original HTML
- msgc.window.MsgBodyAllowHTML();
-
- let textContent =
- msgc.window.msgWindow.messageWindowDocShell.contentViewer.DOMDocument
- .documentElement.textContent;
-
- close_window(msgc);
- return textContent;
-}
-
-/**
- * Checks that the text content is equal for the .eml files.
- */
-function check_eml_textcontent(eml) {
- let textContent = extract_eml_body_textcontent(eml);
- assert_equals(gReferenceTextContent, textContent);
-}
-
-/**
- * This test exercises the bug for reversed http-equiv, content order:
- * <head>
- * <meta content="text/html; charset=ISO-8859-2"; http-equiv="content-type">
- * </head>
- */
-function test_original_html_characters_head_meta_content_charset_httpEq() {
- check_eml_textcontent("./bug594646_reversed_order_8bit.eml");
- check_eml_textcontent("./bug594646_reversed_order_qp.eml");
- check_eml_textcontent("./bug594646_reversed_order_b64.eml");
-}
-
-/**
- * This test exercises the bug for newline delimited charset:
- * <head>
- * <meta http-equiv="content-type" content="text/html;
- * charset=ISO-8859-2">
- * </head>
- */
-function test_original_html_characters_head_meta_httpEq_content_newline_charset() {
- check_eml_textcontent("./bug594646_newline_charset_8bit.eml");
- check_eml_textcontent("./bug594646_newline_charset_qp.eml");
- check_eml_textcontent("./bug594646_newline_charset_b64.eml");
-}
-
-/**
- * This test exercises the bug for newline delimited and reverse ordered http-equiv:
- * <head>
- * <meta content="text/html; charset=ISO-8859-2"
- * http-equiv="content-type">
- * </head>
- */
-function test_original_html_characters_head_meta_content_charset_newline_httpEq() {
- check_eml_textcontent("./bug594646_newline_httpequiv_8bit.eml");
- check_eml_textcontent("./bug594646_newline_httpequiv_qp.eml");
- check_eml_textcontent("./bug594646_newline_httpequiv_b64.eml");
-}
deleted file mode 100644
--- a/mail/test/mozmill/message-window/emptySubject.eml
+++ /dev/null
@@ -1,8 +0,0 @@
-Date: Mon, 10 Jan 2011 12:00:00 -0500
-From: user@example.com
-To: user@example.com
-Subject:
-Content-Type: text/plain
-
-Hello there
-
deleted file mode 100644
--- a/mail/test/mozmill/message-window/evil.eml
+++ /dev/null
@@ -1,7 +0,0 @@
-Date: Mon, 10 Jan 2011 12:00:00 -0500
-From: user@example.com
-To: user@example.com
-Subject: An email
-Content-Type: text/plain
-
-Hello there
deleted file mode 100644
--- a/mail/test/mozmill/message-window/test-alt-HTML-missing.eml
+++ /dev/null
@@ -1,17 +0,0 @@
-From: test <test@example.com>
-Subject: test multipart, HTML missing
-To: test2 <test2@example.com>
-Date: Sat, 27 Feb 2016 17:11:45 +0100
-MIME-Version: 1.0
-Content-Type: multipart/alternative;
- boundary="------------alternative"
-
-This is a multi-part message in MIME format.
---------------alternative
-Content-Type: text/plain; charset=UTF-8; format=flowed
-Content-Transfer-Encoding: 8bit
-
-Plain Text
-
---------------alternative--
-
deleted file mode 100644
--- a/mail/test/mozmill/message-window/test-alt-plain-HTML-reversed.eml
+++ /dev/null
@@ -1,31 +0,0 @@
-From: test <test@example.com>
-Subject: test multipart, plain and HTML reversed
-To: test2 <test2@example.com>
-Date: Sat, 27 Feb 2016 17:11:45 +0100
-MIME-Version: 1.0
-Content-Type: multipart/alternative;
- boundary="------------alternative"
-
-This is a multi-part message in MIME format.
-
---------------alternative
-Content-Type: text/html; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-<html>
- <head>
- <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
- </head>
- <body bgcolor="#FFFFFF" text="#000000">
- HTML Body<br>
- </body>
-</html>
-
---------------alternative
-Content-Type: text/plain; charset=UTF-8; format=flowed
-Content-Transfer-Encoding: 8bit
-
-Plain Text
-
---------------alternative--
-
deleted file mode 100644
--- a/mail/test/mozmill/message-window/test-alt-plain-missing.eml
+++ /dev/null
@@ -1,24 +0,0 @@
-From: test <test@example.com>
-Subject: test multipart, plain part missing
-To: test2 <test2@example.com>
-Date: Sat, 27 Feb 2016 17:11:45 +0100
-MIME-Version: 1.0
-Content-Type: multipart/alternative;
- boundary="------------alternative"
-
-This is a multi-part message in MIME format.
---------------alternative
-Content-Type: text/html; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-<html>
- <head>
- <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
- </head>
- <body bgcolor="#FFFFFF" text="#000000">
- HTML Body<br>
- </body>
-</html>
-
---------------alternative--
-
deleted file mode 100644
--- a/mail/test/mozmill/message-window/test-alt-rel-text.eml
+++ /dev/null
@@ -1,50 +0,0 @@
-From: test <test@example.com>
-Subject: test multipart, alternative first, with image
-To: test2 <test2@example.com>
-Date: Sat, 27 Feb 2016 17:11:45 +0100
-MIME-Version: 1.0
-Content-Type: multipart/alternative;
- boundary="------------alternative"
-
-This is a multi-part message in MIME format.
---------------alternative
-Content-Type: text/plain; charset=UTF-8; format=flowed
-Content-Transfer-Encoding: 8bit
-
-Plain Text
-
---------------alternative
-Content-Type: multipart/related;
- boundary="------------related"
-
-
---------------related
-Content-Type: text/html; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-<html>
- <head>
- <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
- </head>
- <body bgcolor="#FFFFFF" text="#000000">
- HTML Body<br>
- <img src="cid:part1" alt=""><br>
- </body>
-</html>
-
---------------related
-Content-Type: image/png
-Content-Transfer-Encoding: base64
-Content-ID: <part1>
-
-iVBORw0KGgoAAAANSUhEUgAAAAYAAAALCAIAAADTMGvBAAAAEUlEQVQImWPgsi5DQwxDWggA
-lCEwN+YGfiYAAAAASUVORK5CYII=
---------------related--
-
---------------alternative
-Content-Type: text; charset=UTF-8;
-Content-Transfer-Encoding: 8bit
-
-Unspecified text type (not text/plain)
-
---------------alternative--
deleted file mode 100644
--- a/mail/test/mozmill/message-window/test-alt-rel-with-attach.eml
+++ /dev/null
@@ -1,66 +0,0 @@
-From: test <test@example.com>
-Subject: test multipart, alternative first, with image and image attachment
-To: test2 <test2@example.com>
-Date: Sat, 27 Feb 2016 17:11:45 +0100
-MIME-Version: 1.0
-Content-Type: multipart/mixed;
- boundary="------------mixed"
-
-This is a multi-part message in MIME format.
---------------mixed
-Content-Type: multipart/alternative;
- boundary="------------alternative"
-
-
---------------alternative
-Content-Type: text/plain; charset=windows-1252; format=flowed
-Content-Transfer-Encoding: 7bit
-
-Plain Text
-
---------------alternative
-Content-Type: multipart/related;
- boundary="------------related"
-
-
---------------related
-Content-Type: text/html; charset=windows-1252
-Content-Transfer-Encoding: 7bit
-
-<html>
- <head>
-
- <meta http-equiv="content-type" content="text/html; charset=windows-1252">
- </head>
- <body text="#000000" bgcolor="#FFFFFF">
- HTML Body<br>
- <img src="cid:part1.DE278D8E.600E563A@jorgk.com" alt="">
- </body>
-</html>
-
---------------related
-Content-Type: image/png;
- name="llpfblmjefjfhhce.png"
-Content-Transfer-Encoding: base64
-Content-ID: <part1.DE278D8E.600E563A@jorgk.com>
-Content-Disposition: inline;
- filename="llpfblmjefjfhhce.png"
-
-iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAIAAABLbSncAAAAEUlEQVQImWOwCKjBihiGlgQA
-VT9BAeZezQ0AAAAASUVORK5CYII=
---------------related--
-
---------------alternative--
-
---------------mixed
-Content-Type: image/png;
- name="attach.png"
-Content-Transfer-Encoding: base64
-Content-Disposition: attachment;
- filename="attach.png"
-
-iVBORw0KGgoAAAANSUhEUgAAAAkAAAALCAIAAAAiOzBMAAAAAXNSR0IArs4c6QAAAARnQU1B
-AACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAASdEVYdFNvZnR3YXJlAEdyZWVuc2hv
-dF5VCAUAAAAtSURBVChTY3Dx6wYiZ/9OTMTg7A+UIEsOXQiOaCkX0I6JiJBzDMCCcMsFdAIA
-xwttYrvggeAAAAAASUVORK5CYII=
---------------mixed--
deleted file mode 100644
--- a/mail/test/mozmill/message-window/test-alt-rel.eml
+++ /dev/null
@@ -1,45 +0,0 @@
-From: test <test@example.com>
-Subject: test multipart, alternative first, with image
-To: test2 <test2@example.com>
-Date: Sat, 27 Feb 2016 17:11:45 +0100
-MIME-Version: 1.0
-Content-Type: multipart/alternative;
- boundary="------------alternative"
-
-This is a multi-part message in MIME format.
---------------alternative
-Content-Type: text/plain; charset=UTF-8; format=flowed
-Content-Transfer-Encoding: 8bit
-
-Plain Text
-
---------------alternative
-Content-Type: multipart/related;
- boundary="------------related"
-
-
---------------related
-Content-Type: text/html; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-<html>
- <head>
- <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
- </head>
- <body bgcolor="#FFFFFF" text="#000000">
- HTML Body<br>
- <img src="cid:part1" alt=""><br>
- </body>
-</html>
-
---------------related
-Content-Type: image/png
-Content-Transfer-Encoding: base64
-Content-ID: <part1>
-
-iVBORw0KGgoAAAANSUhEUgAAAAYAAAALCAIAAADTMGvBAAAAEUlEQVQImWPgsi5DQwxDWggA
-lCEwN+YGfiYAAAAASUVORK5CYII=
---------------related--
-
---------------alternative--
-
deleted file mode 100644
--- a/mail/test/mozmill/message-window/test-alt-rogue.eml
+++ /dev/null
@@ -1,42 +0,0 @@
-From: test <test@example.com>
-Subject: test multipart, rogue message, last part image
-To: test2 <test2@example.com>
-Date: Sat, 27 Feb 2016 17:11:45 +0100
-MIME-Version: 1.0
-Content-Type: multipart/alternative;
- boundary=--FIRSTboundary
-
-----FIRSTboundary
-Content-Type: multipart/alternative;
- boundary="--SECONDboundary"
-
-----SECONDboundary
-Content-Type: text/plain; charset=utf-8
-
-Plain Text
-
-----SECONDboundary
-Content-Type: text/html; charset=utf-8
-
-<html>
- <head>
- <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
- </head>
- <body bgcolor="#FFFFFF" text="#000000">
- HTML Body<br>
- </body>
-</html>
-
-----SECONDboundary--
-
-----FIRSTboundary
-Content-Transfer-Encoding: base64
-Content-Disposition: inline;
- filename=blue.png
-Content-Type: image/png;
-
-iVBORw0KGgoAAAANSUhEUgAAAAYAAAALCAIAAADTMGvBAAAAEUlEQVQImWPgsi5DQwxDWggA
-lCEwN+YGfiYAAAAASUVORK5CYII=
-
-----FIRSTboundary--
-
deleted file mode 100644
--- a/mail/test/mozmill/message-window/test-alt-rogue2.eml
+++ /dev/null
@@ -1,36 +0,0 @@
-From: test <test@example.com>
-Subject: test multipart, rogue message, last part image
-To: test2 <test2@example.com>
-Date: Sat, 27 Feb 2016 17:11:45 +0100
-MIME-Version: 1.0
-Content-Type: multipart/alternative;
- boundary=--FIRSTboundary
-
-----FIRSTboundary
-Content-Type: text/plain; charset=utf-8
-
-Plain Text
-
-----FIRSTboundary
-Content-Type: text/html; charset=utf-8
-
-<html>
- <head>
- <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
- </head>
- <body bgcolor="#FFFFFF" text="#000000">
- HTML Body<br>
- </body>
-</html>
-
-----FIRSTboundary
-Content-Transfer-Encoding: base64
-Content-Disposition: inline;
- filename=blue.png
-Content-Type: image/png;
-
-iVBORw0KGgoAAAANSUhEUgAAAAYAAAALCAIAAADTMGvBAAAAEUlEQVQImWPgsi5DQwxDWggA
-lCEwN+YGfiYAAAAASUVORK5CYII=
-
-----FIRSTboundary--
-
deleted file mode 100644
--- a/mail/test/mozmill/message-window/test-alt.eml
+++ /dev/null
@@ -1,30 +0,0 @@
-From: test <test@example.com>
-Subject: test multipart, correct plain and HTML
-To: test2 <test2@example.com>
-Date: Sat, 27 Feb 2016 17:11:45 +0100
-MIME-Version: 1.0
-Content-Type: multipart/alternative;
- boundary="------------alternative"
-
-This is a multi-part message in MIME format.
---------------alternative
-Content-Type: text/plain; charset=UTF-8; format=flowed
-Content-Transfer-Encoding: 8bit
-
-Plain Text
-
---------------alternative
-Content-Type: text/html; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-<html>
- <head>
- <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
- </head>
- <body bgcolor="#FFFFFF" text="#000000">
- HTML Body<br>
- </body>
-</html>
-
---------------alternative--
-
deleted file mode 100644
--- a/mail/test/mozmill/message-window/test-autohide-menubar.js
+++ /dev/null
@@ -1,124 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/* Test that the menubar can be set to "autohide". This should only have an
- effect on Windows. */
-
-"use strict";
-
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-
-var { open_address_book_window } = ChromeUtils.import(
- "resource://testing-common/mozmill/AddressBookHelpers.jsm"
-);
-var { close_compose_window, open_compose_new_mail } = ChromeUtils.import(
- "resource://testing-common/mozmill/ComposeHelpers.jsm"
-);
-var {
- be_in_folder,
- close_message_window,
- create_folder,
- make_new_sets_in_folder,
- mc,
- open_selected_message_in_new_window,
- select_click_row,
- toggle_main_menu,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var menuFolder;
-var menuState;
-
-function setupModule(module) {
- menuFolder = create_folder("menuFolder");
- make_new_sets_in_folder(menuFolder, [{ count: 1 }]);
-
- // Make the menubar not autohide by default.
- menuState = toggle_main_menu(true);
-}
-
-/**
- * Set the autohide attribute of the menubar.
- *
- * @param controller the mozmill controller for the window
- * @param elem the element to click on (usually the menubar)
- * @param hide true to hide, false otherwise
- */
-function set_autohide_menubar(controller, elem, hide) {
- let contextMenu = controller.getMenu("#toolbar-context-menu");
- contextMenu.open(new elib.Elem(elem));
- let menuitem = contextMenu.getItem('menuitem[toolbarid="' + elem.id + '"]');
- if (menuitem.getNode().hasAttribute("checked") == hide) {
- // XXX Hack around the fact that calling click doesn't toggle the checked
- // state (bug 670829, bug 670830).
- controller.mouseEvent(menuitem, undefined, undefined, {});
- }
-}
-
-/**
- * Ensure that the autohide attribute of the menubar can be set properly.
- *
- * @param controller the mozmill controller for the window
- * @param menubar the menubar to test
- */
-function help_test_autohide(controller, menubar) {
- function hiddenChecker(aHidden) {
- // The XUL hidden attribute isn't what is set, so it's useless here -- use
- // information from the box model instead.
- return () => (menubar.getBoundingClientRect().height != 0) != aHidden;
- }
- set_autohide_menubar(controller, menubar, true);
- controller.waitFor(hiddenChecker(true), "Menubar should be hidden!");
-
- controller.keypress(new elib.Elem(menubar), "VK_ALT", {});
- controller.waitFor(
- hiddenChecker(false),
- "Menubar should be shown after pressing alt!"
- );
-
- set_autohide_menubar(controller, menubar, false);
- controller.waitFor(hiddenChecker(false), "Menubar should be shown!");
-}
-
-function test_autohidden_menubar_3pane() {
- let menubar = mc.e("mail-toolbar-menubar2");
- help_test_autohide(mc, menubar);
-}
-test_autohidden_menubar_3pane.EXCLUDED_PLATFORMS = ["darwin", "linux"];
-
-function test_autohidden_menubar_message_window() {
- be_in_folder(menuFolder);
- select_click_row(0);
- let msgc = open_selected_message_in_new_window();
- msgc.window.focus();
- let menubar = msgc.e("mail-toolbar-menubar2");
-
- help_test_autohide(msgc, menubar);
- close_message_window(msgc);
-}
-test_autohidden_menubar_message_window.EXCLUDED_PLATFORMS = ["darwin", "linux"];
-
-function test_autohidden_menubar_compose_window() {
- let cwc = open_compose_new_mail();
- let menubar = cwc.e("compose-toolbar-menubar2");
-
- help_test_autohide(cwc, menubar);
- close_compose_window(cwc);
-}
-test_autohidden_menubar_compose_window.EXCLUDED_PLATFORMS = ["darwin", "linux"];
-
-function test_autohidden_menubar_address_book() {
- let abc = open_address_book_window();
- let menubar = abc.e("addrbook-toolbar-menubar2");
-
- help_test_autohide(abc, menubar);
-}
-test_autohidden_menubar_address_book.EXCLUDED_PLATFORMS = ["darwin", "linux"];
-
-function teardownModule() {
- toggle_main_menu(menuState);
-}
deleted file mode 100644
--- a/mail/test/mozmill/message-window/test-commands.js
+++ /dev/null
@@ -1,77 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-var os = ChromeUtils.import("chrome://mozmill/content/stdlib/os.jsm");
-
-var {
- assert_equals,
- be_in_folder,
- create_folder,
- make_new_sets_in_folder,
- mc,
- open_message_from_file,
- press_delete,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { close_window } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var folder1, folder2;
-
-var setupModule = function(module) {
- folder1 = create_folder("CopyFromFolder");
- folder2 = create_folder("CopyToFolder");
- make_new_sets_in_folder(folder1, [{ count: 1 }]);
-};
-
-function test_copy_eml_message() {
- // First, copy an email to a folder and delete it immediately just so it shows
- // up in the recent folders list. This simplifies navigation of the copy
- // context menu.
- be_in_folder(folder1);
- let message = select_click_row(0);
- let array = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
- array.appendElement(message);
- MailServices.copy.CopyMessages(
- folder1,
- array,
- folder2,
- true,
- null,
- mc.window.msgWindow,
- true
- );
- be_in_folder(folder2);
- select_click_row(0);
- press_delete(mc);
-
- // Now, open a .eml file and copy it to our folder.
- let thisFilePath = os.getFileForPath(__file__);
- let file = os.getFileForPath(os.abspath("./evil.eml", thisFilePath));
- let msgc = open_message_from_file(file);
-
- let documentChild = msgc.e("messagepane").contentDocument.firstElementChild;
- msgc.rightClick(new elib.Elem(documentChild));
- msgc.click_menus_in_sequence(msgc.e("mailContext"), [
- { id: "mailContext-copyMenu" },
- { label: "Recent" },
- { label: "CopyToFolder" },
- ]);
- close_window(msgc);
-
- // Make sure the copy worked.
- let copiedMessage = select_click_row(0);
- assert_equals(copiedMessage.mime2DecodedSubject, "An email");
-}
deleted file mode 100644
--- a/mail/test/mozmill/message-window/test-eml-subject.js
+++ /dev/null
@@ -1,56 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests that opening an .eml file with empty subject works.
- */
-
-"use strict";
-
-var os = ChromeUtils.import("chrome://mozmill/content/stdlib/os.jsm");
-
-var { assert_equals, open_message_from_file } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { close_window } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { StringBundle } = ChromeUtils.import(
- "resource:///modules/StringBundle.js"
-);
-var { AppConstants } = ChromeUtils.import(
- "resource://gre/modules/AppConstants.jsm"
-);
-
-var setupModule = function(module) {};
-
-function check_eml_window_title(subject, eml) {
- let file = os.getFileForPath(os.abspath(eml, os.getFileForPath(__file__)));
- let msgc = open_message_from_file(file);
-
- let brandBundle = new StringBundle(
- "chrome://branding/locale/brand.properties"
- );
- let productName = brandBundle.get("brandFullName");
- let expectedTitle = subject;
- if (expectedTitle && AppConstants.platform != "macosx") {
- expectedTitle += " - ";
- }
-
- if (!expectedTitle || AppConstants.platform != "macosx") {
- expectedTitle += productName;
- }
-
- assert_equals(msgc.window.document.title, expectedTitle);
- close_window(msgc);
-}
-
-function test_eml_empty_subject() {
- check_eml_window_title("", "./emptySubject.eml");
-}
-
-function test_eml_normal_subject() {
- check_eml_window_title("An email", "./evil.eml");
-}
deleted file mode 100644
--- a/mail/test/mozmill/message-window/test-message-sidebar.js
+++ /dev/null
@@ -1,13 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-var { mc } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-function test_messagepane_extension_points_exist() {
- mc.assertNode(mc.eid("messagepanewrapper"));
-}
deleted file mode 100644
--- a/mail/test/mozmill/message-window/test-rel-alt.eml
+++ /dev/null
@@ -1,41 +0,0 @@
-From: test <test@example.com>
-Subject: test multipart, related first, with image
-To: test2 <test2@example.com>
-Date: Sat, 27 Feb 2016 17:11:45 +0100
-MIME-Version: 1.0
-Content-Type: multipart/related;
- boundary="------------related"
-
---------------related
-Content-Type: multipart/alternative;
- boundary="------------alternative"
-Content-Type: text/plain; charset=UTF-8; format=flowed
-Content-Transfer-Encoding: 8bit
-
-Plain Text
-
---------------alternative
-Content-Type: text/html; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-<html>
- <head>
- <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
- </head>
- <body bgcolor="#FFFFFF" text="#000000">
- HTML Body<br>
- <img src="cid:part1" alt=""><br>
- </body>
-</html>
-
---------------alternative
-
---------------related
-Content-Type: image/png
-Content-Transfer-Encoding: base64
-Content-ID: <part1>
-
-iVBORw0KGgoAAAANSUhEUgAAAAYAAAALCAIAAADTMGvBAAAAEUlEQVQImWPgsi5DQwxDWggA
-lCEwN+YGfiYAAAAASUVORK5CYII=
-
---------------related--
deleted file mode 100644
--- a/mail/test/mozmill/message-window/test-triple-alt.eml
+++ /dev/null
@@ -1,36 +0,0 @@
-From: "Test tester" <test_mail@example.com>
-To: "Robert Recipient" <robert@example.com>
-Subject: Alternative with 3 parts
-Date: Wed, 26 Sep 2001 09:16:49 -0400
-MIME-Version: 1.0
-Content-Type: multipart/alternative;
- boundary="------------alternative"
-
-This is a multi-part message in MIME format.
-
---------------alternative
-Content-Type: text/plain; charset="iso-8859-1"
-Content-Transfer-Encoding: 7bit
-
-Plain Text
-
---------------alternative
-Content-Type: text/html; charset="iso-8859-1"
-Content-Transfer-Encoding: quoted-printable
-
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<HTML><HEAD></HEAD>
-<BODY>
-
-HTML Body<p>
-
-</BODY>
-</HTML>
-
---------------alternative
-Content-Type: text; charset="iso-8859-1"
-Content-Transfer-Encoding: 8bit
-
-Unspecified text type (not text/plain)
-
---------------alternative--
deleted file mode 100644
--- a/mail/test/mozmill/message-window/test-vcard-actions.js
+++ /dev/null
@@ -1,63 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests for attached vcards.
- */
-
-"use strict";
-
-var os = ChromeUtils.import("chrome://mozmill/content/stdlib/os.jsm");
-
-var { get_cards_in_all_address_books_for_email } = ChromeUtils.import(
- "resource://testing-common/mozmill/AddressBookHelpers.jsm"
-);
-var { assert_equals, open_message_from_file } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var {
- close_window,
- plan_for_modal_dialog,
- wait_for_modal_dialog,
-} = ChromeUtils.import("resource://testing-common/mozmill/WindowHelpers.jsm");
-
-/**
- * Bug 1374779
- * Check if clicking attached vcard image opens new card dialog and adds a contact.
- */
-function test_check_vcard_icon() {
- let file = os.getFileForPath(
- os.abspath("./test-vcard-icon.eml", os.getFileForPath(__file__))
- );
- let msgc = open_message_from_file(file);
-
- let newcards = get_cards_in_all_address_books_for_email(
- "meister@example.com"
- );
- assert_equals(newcards.length, 0);
-
- function subtest_check_card(cardc) {
- // Check new card is properly prefilled.
- let emailField = cardc.e("PrimaryEmail");
- assert_equals(emailField.value, "meister@example.com");
- cardc.window.document.documentElement
- .querySelector("dialog")
- .acceptDialog();
- }
-
- // Click icon on the vcard block.
- let vcard = msgc
- .e("messagepane")
- .contentDocument.querySelector(".moz-vcard-badge");
- // Check new card dialog opens.
- plan_for_modal_dialog("mailnews:newcarddialog", subtest_check_card);
- msgc.click(new elementslib.Elem(vcard));
- wait_for_modal_dialog("mailnews:newcarddialog");
-
- // Check new card was created from the vcard.
- newcards = get_cards_in_all_address_books_for_email("meister@example.com");
- assert_equals(newcards.length, 1);
-
- close_window(msgc);
-}
deleted file mode 100644
--- a/mail/test/mozmill/message-window/test-vcard-icon.eml
+++ /dev/null
@@ -1,41 +0,0 @@
-From - Tue Jun 20 20:58:09 2017
-X-Account-Key: account1
-X-UIDL: UID111111-1111111111
-X-Mozilla-Status: 0001
-X-Mozilla-Status2: 00000000
-X-Mozilla-Keys:
-Delivery-date: Tue, 20 Jun 2017 20:46:01 +0200
-MIME-Version: 1.0
-Message-ID: <vcard@link.invalid>
-From: <meister@mail.example.com>
-To: Hugo <hugo@example.com>
-Subject: Click on inline vCard and hang
-Content-Type: multipart/mixed;
- boundary=sgnirk-111111111111111
-Date: Tue, 20 Jun 2017 20:45:48 +0200
-
---sgnirk-111111111111111
-Content-Type: text/html; charset=UTF-8
-
-<html><head></head>
-<body>
-<div style="font-family: Verdana;font-size: 12.0px;">
-<div>
-<div>
-<div>Hallo Hugo</div>
-
-<div>Set attachments to inline display and click on the addbook: link in the vCard.</div>
-
-</div></div></body></html>
---sgnirk-111111111111111
-Content-Type: text/x-vcard; charset=UTF-8
-Content-Disposition: attachment; filename="Meister.vcf"
-
-BEGIN:VCARD
-VERSION:3.0
-FN:Meister
-EMAIL;TYPE=WORK,PREF:meister@example.com
-END:VCARD
-
---sgnirk-111111111111111--
-
deleted file mode 100644
--- a/mail/test/mozmill/message-window/test-view-plaintext.js
+++ /dev/null
@@ -1,129 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests that the plain text part of multipart/alternative messages can be correctly viewed.
- */
-
-"use strict";
-
-var os = ChromeUtils.import("chrome://mozmill/content/stdlib/os.jsm");
-
-var { assert_false, assert_true, open_message_from_file } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { close_window } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-/**
- * Retrieve the textual content of the message and compare it.
- *
- * @param aWindow Message window.
- * @param aExpected Expected content.
- * @param aDontWantToSee Content of other MIME parts we don't want to see.
- */
-function check_content(aWindow, aExpected, aDontWantToSee) {
- let messagePane = aWindow.document.getElementById("messagepane");
- let messageContent = messagePane.contentDocument.firstChild.textContent;
-
- if (aExpected != aDontWantToSee) {
- assert_true(
- messageContent.includes(aExpected),
- "Didn't find expected content"
- );
- assert_false(
- messageContent.includes(aDontWantToSee),
- "Found content that shouldn't be there"
- );
- } else {
- let ind = messageContent.indexOf(aExpected);
- assert_true(ind >= 0, "Didn't find expected content");
- if (ind >= 0) {
- assert_false(
- messageContent.substr(ind + aExpected.length).includes(aExpected),
- "Found content a second time"
- );
- }
- }
-}
-
-/**
- * Load a message from a file and display it as plain text and HTML. Check that the
- * correct MIME part is displayed.
- *
- * @param aFilePath Path to the file containing the message to load and display.
- * @param aExpectedPlainText Expected content when viewed as plain text.
- * @param aExpectedHTML Expected content when viewed as HTML.
- */
-function checkSingleMessage(aFilePath, aExpectedPlainText, aExpectedHTML) {
- let file = os.getFileForPath(
- os.abspath(aFilePath, os.getFileForPath(__file__))
- );
-
- // Load and display as plain text.
- Services.prefs.setBoolPref("mailnews.display.prefer_plaintext", true);
- Services.prefs.setIntPref("mailnews.display.html_as", 1);
- let msgc = open_message_from_file(file);
- check_content(msgc.window, aExpectedPlainText, aExpectedHTML);
- close_window(msgc);
-
- // Load and display as HTML.
- Services.prefs.setBoolPref("mailnews.display.prefer_plaintext", false);
- Services.prefs.setIntPref("mailnews.display.html_as", 0);
- msgc = open_message_from_file(file);
- check_content(msgc.window, aExpectedHTML, aExpectedPlainText);
- close_window(msgc);
-}
-
-/**
- * Tests that messages with various MIME parts are shown correctly when displayed
- * as plain text or HTML.
- */
-function test_view() {
- // First the straight forward tests:
- // 1) multipart/alternative
- // 2) multipart/alternative with embedded multipart/related
- // 3) multipart/alternative with embedded multipart/related embedded in multipart/mixed
- checkSingleMessage("./test-alt.eml", "Plain Text", "HTML Body");
- checkSingleMessage("./test-alt-rel.eml", "Plain Text", "HTML Body");
- checkSingleMessage(
- "./test-alt-rel-with-attach.eml",
- "Plain Text",
- "HTML Body"
- );
-
- // 4) HTML part missing
- // 5) Plain part missing
- checkSingleMessage("./test-alt-HTML-missing.eml", "Plain Text", "Plain Text");
- checkSingleMessage("./test-alt-plain-missing.eml", "HTML Body", "HTML Body");
-
- // 6) plain and HTML parts reversed in order
- checkSingleMessage(
- "./test-alt-plain-HTML-reversed.eml",
- "Plain Text",
- "HTML Body"
- );
-
- // 7) 3 alt. parts with 2 plain and 1 HTML part
- checkSingleMessage("./test-triple-alt.eml", "Plain Text", "HTML Body");
-
- // 8) 3 alt. parts with 2 plain and 1 multipart/related
- checkSingleMessage("./test-alt-rel-text.eml", "Plain Text", "HTML Body");
-
- // Now some cases that don't work yet.
- // 9) multipart/related with embedded multipart/alternative
- checkSingleMessage("./test-rel-alt.eml", "HTML Body", "HTML Body");
-
- // Bug 1367156: Rogue message which has an image as the last part.
- checkSingleMessage("./test-alt-rogue.eml", "Plain Text", "HTML Body");
- checkSingleMessage("./test-alt-rogue2.eml", "Plain Text", "HTML Body");
-}
-
-function teardownModule() {
- Services.prefs.clearUserPref("mailnews.display.prefer_plaintext");
- Services.prefs.clearUserPref("mailnews.display.html_as");
-}
deleted file mode 100644
--- a/mail/test/mozmill/moz.build
+++ /dev/null
@@ -1,66 +0,0 @@
-# vim: set filetype=python:
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-TEST_HARNESS_FILES.mozmill += [
- 'mozmilltests.list',
- 'runtest.py',
- 'runtestlist.py',
-]
-
-TEST_HARNESS_FILES.mozmill.resources += [
- '/{}/mail/base/test/unit/resources/viewWrapperTestUtils.js'.format(CONFIG['commreltopsrcdir']),
- '/{}/mail/test/resources/*'.format(CONFIG['commreltopsrcdir']),
-]
-
-
-def mailnews_files(files, comm=CONFIG['commreltopsrcdir']):
- return [
- '/{comm}/mailnews/{file}'.format(
- comm=comm,
- file=file,
- ) for file in files
- ]
-
-TEST_HARNESS_FILES.mozmill.fakeserver += mailnews_files([
- 'test/fakeserver/auth.js',
- 'test/fakeserver/imapd.js',
- 'test/fakeserver/maild.js',
- 'test/fakeserver/nntpd.js',
- 'test/fakeserver/pop3d.js',
- 'test/fakeserver/smtpd.js',
-])
-
-
-TEST_HARNESS_FILES.mozmill.resources += mailnews_files([
- 'test/resources/asyncTestUtils.js',
- 'test/resources/folderEventLogHelper.js',
- 'test/resources/logHelper.js',
- 'test/resources/messageGenerator.js',
- 'test/resources/messageInjection.js',
- 'test/resources/messageModifier.js',
- 'test/resources/smimeUtils.jsm',
-])
-
-DIRS += [
- 'shared-modules',
-]
-
-TESTING_JS_MODULES.mozmill += [
- '../resources/mozmill/mozmill/extension/content/modules/controller.jsm',
- '../resources/mozmill/mozmill/extension/content/modules/elementslib.jsm',
- '../resources/mozmill/mozmill/extension/content/modules/events.jsm',
- '../resources/mozmill/mozmill/extension/content/modules/frame.jsm',
- '../resources/mozmill/mozmill/extension/content/modules/init.jsm',
- '../resources/mozmill/mozmill/extension/content/modules/jum.jsm',
- '../resources/mozmill/mozmill/extension/content/modules/mozmill.jsm',
- '../resources/mozmill/mozmill/extension/content/modules/utils.jsm',
- '../resources/mozmill/mozmill/extension/content/stdlib/arrays.jsm',
- '../resources/mozmill/mozmill/extension/content/stdlib/dom.jsm',
- '../resources/mozmill/mozmill/extension/content/stdlib/EventUtils.jsm',
- '../resources/mozmill/mozmill/extension/content/stdlib/httpd.jsm',
- '../resources/mozmill/mozmill/extension/content/stdlib/os.jsm',
- '../resources/mozmill/mozmill/extension/content/stdlib/securable-module.jsm',
- '../resources/mozmill/mozmill/extension/content/stdlib/strings.jsm',
-]
deleted file mode 100644
--- a/mail/test/mozmill/mozmilltests.list
+++ /dev/null
@@ -1,33 +0,0 @@
-account
-addrbook
-attachment
-cloudfile
-composition
-content-policy
-content-tabs
-cookies
-downloads
-folder-display
-folder-pane
-folder-tree-modes
-folder-widget
-im
-instrumentation
-junk-commands
-keyboard
-message-header
-message-reader
-message-window
-multiple-identities
-newmailaccount
-notification
-override-main-menu-collapse
-pref-window
-quick-filter-bar
-search-window
-session-store
-smime
-startup-firstrun
-subscribe
-tabmail
-utils
deleted file mode 100644
--- a/mail/test/mozmill/multiple-identities/readme.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-Caution! The tests in this directory modify or outright delete the default
-accounts/identities. If you are writing new tests to go into this directory,
-don't assume the existence of any account except Local Folders (with a single
-identity).
deleted file mode 100644
--- a/mail/test/mozmill/multiple-identities/test-display-names.js
+++ /dev/null
@@ -1,205 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test that we can open and close a standalone message display window from the
- * folder pane.
- */
-
-"use strict";
-
-var { ensure_card_exists, ensure_no_card_exists } = ChromeUtils.import(
- "resource://testing-common/mozmill/AddressBookHelpers.jsm"
-);
-var {
- add_message_to_folder,
- assert_true,
- be_in_folder,
- create_folder,
- create_message,
- mc,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-var folder;
-var decoyFolder;
-var localAccount;
-var secondIdentity;
-var myEmail = "sender@nul.invalid"; // Dictated by messagerInjector.js
-var friendEmail = "carl@sagan.invalid";
-var friendName = "Carl Sagan";
-var headertoFieldMe;
-var collectedAddresses;
-
-function setupModule(module) {
- localAccount = MailServices.accounts.FindAccountForServer(
- MailServices.accounts.localFoldersServer
- );
-
- // We need to make sure we have only one identity:
- // 1) Delete all accounts except for Local Folders
- for (let i = MailServices.accounts.accounts.length - 1; i >= 0; i--) {
- let account = MailServices.accounts.accounts.queryElementAt(
- i,
- Ci.nsIMsgAccount
- );
- if (account != localAccount) {
- MailServices.accounts.removeAccount(account);
- }
- }
-
- // 2) Delete all identities except for one
- for (let i = localAccount.identities.length - 1; i >= 0; i--) {
- let identity = localAccount.identities.queryElementAt(i, Ci.nsIMsgIdentity);
- if (identity.email != myEmail) {
- localAccount.removeIdentity(identity);
- }
- }
-
- // 3) Create a second identity and hold onto it for later
- secondIdentity = MailServices.accounts.createIdentity();
- secondIdentity.email = "nobody@nowhere.invalid";
-
- folder = create_folder("DisplayNamesA");
- decoyFolder = create_folder("DisplayNamesB");
-
- add_message_to_folder(folder, create_message({ to: [["", myEmail]] }));
- add_message_to_folder(folder, create_message({ from: ["", friendEmail] }));
- add_message_to_folder(
- folder,
- create_message({ from: [friendName, friendEmail] })
- );
-
- // Ensure all the directories are initialised.
- MailServices.ab.directories;
- collectedAddresses = MailServices.ab.getDirectory(
- "jsaddrbook://history.sqlite"
- );
-
- let bundle = Services.strings.createBundle(
- "chrome://messenger/locale/messenger.properties"
- );
- headertoFieldMe = bundle.GetStringFromName("headertoFieldMe");
-}
-
-function ensure_single_identity() {
- if (localAccount.identities.length > 1) {
- localAccount.removeIdentity(secondIdentity);
- }
- assert_true(
- MailServices.accounts.allIdentities.length == 1,
- "Expected 1 identity, but got " +
- MailServices.accounts.allIdentities.length +
- " identities"
- );
-}
-
-function ensure_multiple_identities() {
- if (localAccount.identities.length == 1) {
- localAccount.addIdentity(secondIdentity);
- }
- assert_true(
- MailServices.accounts.allIdentities.length > 1,
- "Expected multiple identities, but got only one identity"
- );
-}
-
-function help_test_display_name(message, field, expectedValue) {
- // Switch to a decoy folder first to ensure that we refresh the message we're
- // looking at in order to update information changed in address book entries.
- be_in_folder(decoyFolder);
- be_in_folder(folder);
- select_click_row(message);
-
- let value = mc
- .e("expanded" + field + "Box", { tagName: "mail-emailaddress" })
- .querySelector(".emaillabel").value;
-
- if (value != expectedValue) {
- throw new Error("got '" + value + "' but expected '" + expectedValue + "'");
- }
-}
-
-function test_single_identity() {
- ensure_no_card_exists(myEmail);
- ensure_single_identity();
- help_test_display_name(0, "to", headertoFieldMe);
-}
-
-function test_single_identity_in_abook() {
- ensure_card_exists(myEmail, "President Frankenstein", true);
- ensure_single_identity();
- help_test_display_name(0, "to", "President Frankenstein");
-}
-
-function test_single_identity_in_abook_no_pdn() {
- ensure_card_exists(myEmail, "President Frankenstein");
- ensure_single_identity();
- help_test_display_name(0, "to", headertoFieldMe);
-}
-
-function test_multiple_identities() {
- ensure_no_card_exists(myEmail);
- ensure_multiple_identities();
- help_test_display_name(0, "to", headertoFieldMe + " <" + myEmail + ">");
-}
-
-function test_multiple_identities_in_abook() {
- ensure_card_exists(myEmail, "President Frankenstein", true);
- ensure_multiple_identities();
- help_test_display_name(0, "to", "President Frankenstein");
-}
-
-function test_multiple_identities_in_abook_no_pdn() {
- ensure_card_exists(myEmail, "President Frankenstein");
- ensure_multiple_identities();
- help_test_display_name(0, "to", headertoFieldMe + " <" + myEmail + ">");
-}
-
-function test_no_header_name() {
- ensure_no_card_exists(friendEmail);
- ensure_single_identity();
- help_test_display_name(1, "from", friendEmail);
-}
-
-function test_no_header_name_in_abook() {
- ensure_card_exists(friendEmail, "My Buddy", true);
- ensure_single_identity();
- help_test_display_name(1, "from", "My Buddy");
-}
-
-function test_no_header_name_in_abook_no_pdn() {
- ensure_card_exists(friendEmail, "My Buddy");
- ensure_single_identity();
- // With address book entry but display name not preferred, we display name and
- // e-mail address or only the e-mail address if no name exists.
- help_test_display_name(1, "from", "carl@sagan.invalid");
-}
-
-function test_header_name() {
- ensure_no_card_exists(friendEmail);
- ensure_single_identity();
- help_test_display_name(2, "from", friendName + " <" + friendEmail + ">");
-}
-
-function test_header_name_in_abook() {
- ensure_card_exists(friendEmail, "My Buddy", true);
- ensure_single_identity();
- help_test_display_name(2, "from", "My Buddy");
-}
-
-function test_header_name_in_abook_no_pdn() {
- ensure_card_exists(friendEmail, "My Buddy");
- ensure_single_identity();
- // With address book entry but display name not preferred, we display name and
- // e-mail address.
- help_test_display_name(2, "from", "Carl Sagan <carl@sagan.invalid>");
-}
deleted file mode 100644
--- a/mail/test/mozmill/newmailaccount/html/badSuggestFromName
+++ /dev/null
@@ -1,4 +0,0 @@
-
-[{"product": "personalized_email", "addresses": ["green@foo.invalid",
-"green_llama@foo.invalid", "gllama@bar.cbar"}, {"product":
-, "price": "20.00", "provider": "fo"]w
deleted file mode 100644
--- a/mail/test/mozmill/newmailaccount/html/config.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<clientConfig version="1.1">
- <emailProvider id="%DOMAIN%">
- <domain>%EMAILDOMAIN%</domain>
- <displayName>Provisioned Account</displayName>
- <displayShortName>Provisioned Account</displayShortName>
- <incomingServer type="imap">
- <hostname>imap.%EMAILDOMAIN%</hostname>
- <port>993</port>
- <socketType>SSL</socketType>
- <username>%EMAILADDRESS%</username>
- <authentication>password-cleartext</authentication>
- <password>Testing</password>
- </incomingServer>
- <incomingServer type="pop3">
- <hostname>pop.%EMAILDOMAIN%</hostname>
- <port>995</port>
- <socketType>SSL</socketType>
- <username>%EMAILLOCALPART%</username>
- <authentication>password-cleartext</authentication>
- <password>Testing</password>
- <pop3>
- <leaveMessagesOnServer>true</leaveMessagesOnServer>
- </pop3>
- </incomingServer>
- <outgoingServer type="smtp">
- <hostname>smtp.%EMAILDOMAIN%</hostname>
- <port>465</port>
- <socketType>SSL</socketType>
- <username>%EMAILADDRESS%</username>
- <authentication>password-cleartext</authentication>
- <password>Testing</password>
- </outgoingServer>
- </emailProvider>
-</clientConfig>
deleted file mode 100644
--- a/mail/test/mozmill/newmailaccount/html/configCorrupt.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<clientConfig versi">
- <emailProvider id="%DOMAIN%">
- <domain>%EMAILDOMAIN%</domain>
- <displayName>Provisioned Account</displayName>
- <displayShortName>Provisioned Account</displayShortName>
- <incomingServer type="imap">
- <hostname>imap.%EMAILDOMAIN%</hostname>
- <socketType>SSL</socketType>
- <username>%EMAILADDRESS%</username>
- <authentication>password-cleartext</authentication>
- </incomingServer>
- <incomingServer type="pop3">
- <username>%EMAILLOCALPART%</username>
- <authentication>password-cleartext</authentication>
- <password>Testing</password>
- <pop3>
- </pop3>
- </incomingServer>
- <outgoingServer type="smtp">
- <hostname>smtp.%EMAILDOMAIN%</hostname>
- <por465</port>
- <socketType>SSL</socketType>
- <username>%EMAILADDRESS%</username>
- <autddhentication>password-cleartext</authentication>
- </outgoingServer>
deleted file mode 100644
--- a/mail/test/mozmill/newmailaccount/html/configError.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<clientConfig version="1.1">
- <emailProvider id="%DOMAIN%"/>
- <error code="USER_CANCEL">
- You have cancelled your order.
- </error>
-</clientConfig>
deleted file mode 100644
--- a/mail/test/mozmill/newmailaccount/html/emptySuggestFromName
+++ /dev/null
@@ -1,1 +0,0 @@
-{}
deleted file mode 100644
--- a/mail/test/mozmill/newmailaccount/html/providerList
+++ /dev/null
@@ -1,60 +0,0 @@
-[{"id": "foo",
- "label": "foo",
- "paid": true,
- "languages" : ["en-US"],
- "api": "http://www.example.com/tbReg?first={firstname}&last={lastname}&email={email}",
- "tos_url": "http://www.example.com/foo-tos",
- "privacy_url": "http://www.example.com/foo-privacy",
- "search_engine": "foo"
- },
- {"id": "bar",
- "label": "bar",
- "paid": false,
- "languages" : ["en-US", "fr-FR"],
- "api": "http://localhost:43336/registration.html",
- "tos_url": "http://www.example.com/bar-tos",
- "privacy_url": "http://www.example.com/bar-privacy",
- "search_engine": "bar"
- },
- {"id": "French",
- "label": "French Provider",
- "paid": false,
- "languages" : ["fr-FR"],
- "api": "http://localhost:43336/registration.html",
- "tos_url": "http://www.example.com/French-tos",
- "privacy_url": "http://www.example.com/French-privacy",
- "search_engine": "French"
- },
- {"id": "German",
- "label": "German Provider",
- "paid": false,
- "languages" : ["de-DE"],
- "api": "http://localhost:43336/registration.html",
- "tos_url": "http://www.example.com/German-tos",
- "privacy_url": "http://www.example.com/German-privacy",
- "search_engine": "German"
- },
- {"id": "corrupt",
- "label": "Corrupt Provider",
- "paid": false,
- "languages" : ["en-US"],
- "api": "http://localhost:43336/registrationCorrupt.html",
- "tos_url": "http://www.example.com/corrupt-tos",
- "privacy_url": "http://www.example.com/corrupt-privacy"
- },
- {"id": "err",
- "label": "Error Provider",
- "paid": false,
- "languages" : ["en-US"],
- "api": "http://localhost:43336/registrationError.html",
- "tos_url": "http://www.example.com/err-tos",
- "privacy_url": "http://www.example.com/err-privacy"
- },
- {"id": "multi",
- "label": "multi",
- "paid": true,
- "languages" : ["en-US"],
- "api": "http://localhost:43336/registration.html",
- "tos_url": "http://www.example.com/bar-tos",
- "privacy_url": "http://www.example.com/bar-privacy"
- }]
deleted file mode 100644
--- a/mail/test/mozmill/newmailaccount/html/providerListBad
+++ /dev/null
@@ -1,15 +0,0 @@
-[{"id": "foo",
- "label": "foo",
- "paid": true,
- "languages" : ["en-US"],
- "api": "http://www.example.com/tbReg?first={firstname}&last={lastname}&email={email}",
- "url": "http://www.example.com/api/orde"http://foo.com/tos",
- "privacy_url": "http://foo.com/privacy",
- "search_engine": "foo"
- },
-: "http://example.com/",
- "tos_url": "http://example.com/tos",
- "privacy_url": "http://example.com/privacy"
-}
-
-]
deleted file mode 100644
--- a/mail/test/mozmill/newmailaccount/html/providerListIncomplete
+++ /dev/null
@@ -1,41 +0,0 @@
-[{"id": "foo",
- "label": "foo",
- "paid": true,
- "languages" : ["en-US"],
- "api": "http://www.example.com/tbReg?first={firstname}&last={lastname}&email={email}",
- "tos_url": "http://www.example.com/tos",
- "privacy_url": "http://www.example.com/privacy",
- "search_engine": "foo"
- },
- {"id": "bar",
- "label": "bar",
- "paid": false,
- "languages" : ["en-US", "fr-FR"],
- "api": "http://localhost:43336/registration.html",
- "tos_url": "http://www.example.com/tos",
- "privacy_url": "http://www.example.com/privacy",
- "search_engine": "bar"
- },
- {"id": "French",
- "label": "French Provider",
- "paid": false,
- "languages" : ["fr-FR"],
- "api": "http://localhost:43336/registration.html",
- "tos_url": "http://www.example.com/tos",
- "privacy_url": "http://www.example.com/privacy",
- "search_engine": "French"
- },
- {"id": "German",
- "label": "German Provider",
- "paid": false,
- "languages" : ["de-DE"],
- "api": "http://localhost:43336/registration.html",
- "tos_url": "http://www.example.com/tos",
- "privacy_url": "http://www.example.com/privacy",
- "search_engine": "German"
-},
- {"id": "corrupt",
- "label": "Corrupt Provider",
- "languages" : ["en-US"],
- "api": "http://localhost:43336/registrationCorrupt.html"
-}]
deleted file mode 100644
--- a/mail/test/mozmill/newmailaccount/html/providerListNoOtherLangs
+++ /dev/null
@@ -1,28 +0,0 @@
-[{"id": "foo",
- "label": "foo",
- "paid": true,
- "languages" : ["en-US"],
- "api": "http://www.example.com/tbReg?first={firstname}&last={lastname}&email={email}",
- "tos_url": "http://www.example.com/foo-tos",
- "privacy_url": "http://www.example.com/foo-privacy",
- "search_engine": "foo"
- },
- {"id": "bar",
- "label": "bar",
- "paid": false,
- "languages" : ["en-US"],
- "api": "http://localhost:43336/registration.html",
- "tos_url": "http://www.example.com/bar-tos",
- "privacy_url": "http://www.example.com/bar-privacy",
- "search_engine": "bar"
- },
- {"id": "corrupt",
- "label": "Corrupt Provider",
- "paid": false,
- "languages" : ["en-US"],
- "api": "http://localhost:43336/registrationCorrupt.html",
- "tos_url": "http://www.example.com/corrupt-tos",
- "privacy_url": "http://www.example.com/corrupt-privacy"
-}
-
-]
deleted file mode 100644
--- a/mail/test/mozmill/newmailaccount/html/providerListWildcard
+++ /dev/null
@@ -1,37 +0,0 @@
-[{"id": "universal",
- "label": "Universal",
- "paid": true,
- "languages" : ["*"],
- "api": "http://www.example.com/tbReg?first={firstname}&last={lastname}&email={email}",
- "tos_url": "http://www.example.com/foo-tos",
- "privacy_url": "http://www.example.com/foo-privacy",
- "search_engine": "universal"
- },
-{"id": "otherUniversal",
- "label": "Other Universal",
- "paid": true,
- "languages" : ["*", "fr-FR"],
- "api": "http://www.example.com/tbReg?first={firstname}&last={lastname}&email={email}",
- "tos_url": "http://www.example.com/foo-tos",
- "privacy_url": "http://www.example.com/foo-privacy",
- "search_engine": "otherUniversal"
- },
- {"id": "French",
- "label": "French Provider",
- "paid": false,
- "languages" : ["fr-FR"],
- "api": "http://localhost:43336/registration.html",
- "tos_url": "http://www.example.com/French-tos",
- "privacy_url": "http://www.example.com/French-privacy",
- "search_engine": "French"
- },
- {"id": "German",
- "label": "German Provider",
- "paid": false,
- "languages" : ["de-DE"],
- "api": "http://localhost:43336/registration.html",
- "tos_url": "http://www.example.com/German-tos",
- "privacy_url": "http://www.example.com/German-privacy",
- "search_engine": "German"
- }
-]
deleted file mode 100644
--- a/mail/test/mozmill/newmailaccount/html/registration.html
+++ /dev/null
@@ -1,25 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
- <head>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8">
- <title>Fake registration page</title>
- </head>
- <body>
- <div class="title">Local version</div>
- <div class="content">
- <form action="config.xml" method="GET">
- <p>
- First name: <input value="Green" id="first" name="firstname" type="text"><br>
- Last name: <input value="Llama" id="last" name="lastname" type="text"><br>
- Email: <input value="da.green.llama@foo.invalid" id="email" name="email" type="text"><br>
- <input value="Send" type="submit">
- </p>
- </form>
- <a id="external" href="target.html" target="_blank">Should open externally</a>
- <a id="internal" href="target.html">Should open internally</a>
- <p id="newtab" onclick="window.open('target.html');">
- Should open in a new content tab.
- </p>
- </div>
- </body>
-</html>
deleted file mode 100644
--- a/mail/test/mozmill/newmailaccount/html/registrationCorrupt.html
+++ /dev/null
@@ -1,21 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
- <head>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8">
- <title>Fake registration page to Corrupt XML</title>
- </head>
- <body>
-
- <div class="title">Local version</div>
- <div class="content">
- <form action="configCorrupt.xml" method="GET">
- <p>
- First name: <input value="Green" id="first" name="firstname" type="text"><br>
- Last name: <input value="Llama" id="last" name="lastname" type="text"><br>
- Email: <input value="da.green.llama@example.com" id="email" name="email" type="text"><br>
- <input value="Send" type="submit">
- </p>
- </form>
- </div>
- </body>
-</html>
deleted file mode 100644
--- a/mail/test/mozmill/newmailaccount/html/registrationError.html
+++ /dev/null
@@ -1,21 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
- <head>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8">
- <title>Fake registration page to Error XML</title>
- </head>
- <body>
-
- <div class="title">Local version</div>
- <div class="content">
- <form action="configError.xml" method="GET">
- <p>
- First name: <input value="Green" id="first" name="firstname" type="text"><br>
- Last name: <input value="Llama" id="last" name="lastname" type="text"><br>
- Email: <input value="da.green.llama@example.com" id="email" name="email" type="text"><br>
- <input value="Send" type="submit">
- </p>
- </form>
- </div>
- </body>
-</html>
deleted file mode 100644
--- a/mail/test/mozmill/newmailaccount/html/suggestFromName
+++ /dev/null
@@ -1,13 +0,0 @@
-[{"product": "personalized_email", "addresses": ["green@example.com",
-"green_llama@example.com", "gllama@example.com"], "succeeded": true, "quote":
-"b28acb3c0a464d33af22", "price": 0, "provider": "bar"}, {"product":
-"personalized_email", "addresses": ["green-bar@example.com", "me-bar@example.com",
-"green-bar@madeup.invalid", "green@bar.invalid", "green@barexample.invalid",
-"greenbar@greenllama.invalid", "mebar@greenllama.invalid"], "succeeded": true, "quote":
-"3f93e48679ab46a49475", "price": "20.00", "provider": "foo"},
-{"product": "personalized_email", "addresses": ["corrupt@corrupt.invalid"],
-"succeeded": true, "quote": "abcdefg", "price": 0, "provider": "corrupt"},
-{"product": "personalized_email", "addresses": ["error@error.invalid"],
-"succeeded": true, "quote": "abcdefg", "price": 0, "provider": "err"},
-{"addresses": ["default@example.com", {"address": "cheap@example.com", "price": "0"},
-{"address": "expensive@example.com", "price": "$20.00"}], "succeeded": true, "price": "$20-$0", "provider": "multi"}]
deleted file mode 100644
--- a/mail/test/mozmill/newmailaccount/html/target.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
- <head>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8">
- <title>Well, how do you do!</title>
- </head>
- <body>
- <h1>Testing, testing, 1..2..3..</h1>
- </body>
-</html>
deleted file mode 100644
--- a/mail/test/mozmill/newmailaccount/test-newmailaccount.js
+++ /dev/null
@@ -1,1470 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests the get an account (account provisioning) workflow.
- */
-
-"use strict";
-
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-var { HttpServer } = ChromeUtils.import(
- "chrome://mozmill/content/stdlib/httpd.jsm"
-);
-
-var {
- gMockExtProtSvc,
- gMockExtProtSvcReg,
- open_content_tab_with_click,
- plan_for_content_tab_load,
- wait_for_content_tab_load,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/ContentTabHelpers.jsm"
-);
-var {
- assert_element_visible,
- wait_for_element_enabled,
- wait_for_element_invisible,
- wait_for_element_visible,
-} = ChromeUtils.import("resource://testing-common/mozmill/DOMHelpers.jsm");
-var {
- assert_equals,
- assert_false,
- assert_not_equals,
- assert_selected_tab,
- assert_true,
- mc,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var {
- assert_links_not_shown,
- assert_links_shown,
- gConsoleListener,
- open_provisioner_window,
- remove_email_account,
- type_in_search_name,
- wait_for_provider_list_loaded,
- wait_for_search_ready,
- wait_for_search_results,
- wait_for_the_wizard_to_be_closed,
- wait_to_be_offline,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/NewMailAccountHelpers.jsm"
-);
-var {
- close_window,
- plan_for_modal_dialog,
- plan_for_new_window,
- plan_for_window_close,
- wait_for_browser_load,
- wait_for_modal_dialog,
- wait_for_new_window,
- wait_for_window_close,
-} = ChromeUtils.import("resource://testing-common/mozmill/WindowHelpers.jsm");
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-// RELATIVE_ROOT messes with the collector, so we have to bring the path back
-// so we get the right path for the resources.
-var url = collector.addHttpResource("../newmailaccount/html", "");
-var kProvisionerUrl =
- "chrome://messenger/content/newmailaccount/accountProvisioner.xhtml";
-var kProvisionerEnabledPref = "mail.provider.enabled";
-var kSuggestFromNamePref = "mail.provider.suggestFromName";
-var kProviderListPref = "mail.provider.providerList";
-var kDefaultServerPort = 4444;
-var kDefaultServerRoot = "http://localhost:" + kDefaultServerPort;
-
-Services.prefs.setCharPref(kProviderListPref, url + "providerList");
-Services.prefs.setCharPref(kSuggestFromNamePref, url + "suggestFromName");
-
-// Here's a name that we'll type in later on. It's a global const because
-// we'll be using it in several distinct modal dialog event loops.
-var NAME = "Leonard Shelby";
-
-// Record what the original value of the mail.provider.enabled pref is so
-// that we can put it back once the tests are done.
-var gProvisionerEnabled = Services.prefs.getBoolPref(kProvisionerEnabledPref);
-var gOldAcceptLangs = Services.locale.requestedLocales;
-var gNumAccounts;
-
-function setupModule(module) {
- // Make sure we enable the Account Provisioner.
- Services.prefs.setBoolPref(kProvisionerEnabledPref, true);
- // Restrict the user's language to just en-US
- Services.locale.requestedLocales = ["en-US"];
-
- // Add a "bar" search engine that we can switch to be the default.
- let engineAdded = false;
- Services.search
- .addEngineWithDetails("bar", {
- method: "post",
- template: "http://www.example.com/search?q={searchTerms}",
- })
- .then(() => (engineAdded = true));
- mc.waitFor(() => engineAdded);
-}
-
-function teardownModule(module) {
- // Put the mail.provider.enabled pref back the way it was.
- Services.prefs.setBoolPref(kProvisionerEnabledPref, gProvisionerEnabled);
- // And same with the user languages
- Services.locale.requestedLocales = gOldAcceptLangs;
-}
-
-/* Helper function that returns the number of accounts associated with the
- * current profile.
- */
-function nAccounts() {
- return MailServices.accounts.accounts.length;
-}
-
-/**
- * This tests the basic workflow for Account Provisioner - it spawns the
- * Provisioner window, fills in the search input, gets the results, clicks
- * on an address, completes a dummy form in a new tab for getting the account,
- * and then sets the provider as the default search engine.
- *
- * It gets a little complicated, since the modal dialog for the provisioner
- * spins it's own event loop, so we have to have subtest functions. Therefore,
- * this test is split over 3 functions, and uses a global gNumAccounts. The
- * three functions are "test_get_an_account", "subtest_get_an_account",
- * and "subtest_get_an_account_part_2".
- *
- * @param aCloseAndRestore a boolean for whether or not we should close and
- * restore the Account Provisioner tab before filling
- * in the form. Defaults to false.
- */
-function test_get_an_account(aCloseAndRestore) {
- let originalEngine = Services.search.defaultEngine;
- // Open the provisioner - once opened, let subtest_get_an_account run.
- plan_for_modal_dialog("AccountCreation", subtest_get_an_account);
- open_provisioner_window();
- wait_for_modal_dialog("AccountCreation");
-
- // Once we're here, subtest_get_an_account has completed, and we're waiting
- // for a content tab to load for the account order form.
-
- // Make sure the page is loaded.
- wait_for_content_tab_load(undefined, function(aURL) {
- return aURL.host == "localhost";
- });
-
- let tab = mc.tabmail.currentTabInfo;
-
- if (aCloseAndRestore) {
- // Close the account provisioner tab, and then restore it...
- mc.tabmail.closeTab(mc.tabmail.currentTabInfo);
- mc.tabmail.undoCloseTab();
- // Wait for the page to be loaded again...
- wait_for_content_tab_load(undefined, function(aURL) {
- return aURL.host == "localhost";
- });
- tab = mc.tabmail.currentTabInfo;
- }
-
- // Record how many accounts we start with.
- gNumAccounts = nAccounts();
-
- // Plan for the account provisioner window to re-open, and then run the
- // controller through subtest_get_an_account_part_2. Since the Account
- // Provisioner dialog is non-modal in the event of success, we use our
- // normal window handlers.
- plan_for_new_window("AccountCreation");
-
- // Click the OK button to order the account.
- let btn = tab.browser.contentWindow.document.querySelector(
- "input[value=Send]"
- );
- mc.click(new elib.Elem(btn));
-
- let ac = wait_for_new_window("AccountCreation");
-
- plan_for_window_close(ac);
- subtest_get_an_account_part_2(ac);
- wait_for_window_close();
-
- // Make sure we set the default search engine
- let engine = Services.search.getEngineByName("bar");
- assert_equals(engine, Services.search.defaultEngine);
-
- // Restore the original search engine.
- Services.search.defaultEngine = originalEngine;
- remove_email_account("green@example.com");
-}
-
-/**
- * This is a subtest for test_get_an_account, and runs the first time the
- * account provisioner window is opened.
- */
-function subtest_get_an_account(w) {
- // Make sure we don't have bar as the default engine yet.
- let engine = Services.search.getEngineByName("bar");
- assert_not_equals(engine, Services.search.defaultEngine);
-
- wait_for_provider_list_loaded(w);
- wait_for_search_ready(w);
-
- // Fill in some data
- type_in_search_name(w, "Green Llama");
-
- w.click(w.eid("searchSubmit"));
- wait_for_search_results(w);
-
- // Click on the first address. This reveals the button with the price.
- let address = w.window.document.querySelector(".address:first-child");
- w.click(new elib.Elem(address));
- w.waitFor(
- () =>
- w.window.document.querySelectorAll('button.create:not([disabled="true"])')
- .length > 0
- );
-
- // Pick the email address green@example.com
- plan_for_content_tab_load();
-
- // Clicking this button should close the modal dialog.
- let button = w.window.document.querySelector(
- 'button.create[address="green@example.com"]'
- );
- w.click(new elib.Elem(button));
-}
-
-/**
- * This is a subtest for test_get_an_account, and runs the second time the
- * account provisioner window is opened.
- */
-function subtest_get_an_account_part_2(w) {
- // An account should have been added.
- assert_equals(nAccounts(), gNumAccounts + 1);
-
- // We want this provider to be our default search engine.
- wait_for_element_invisible(w, "window");
- wait_for_element_visible(w, "successful_account");
-
- // Make sure the search engine is checked
- assert_true(w.e("search_engine_check").checked);
-
- // Then click "Finish"
- mc.click(w.eid("closeWindow"));
-}
-
-/**
- * Runs test_get_an_account again, but this time, closes and restores the
- * order form tab before submitting it.
- */
-function test_restored_ap_tab_works() {
- test_get_an_account(true);
-}
-
-/**
- * Test that clicking on the "I think I'll configure my account later"
- * button dismisses the Account Provisioner window.
- */
-function test_can_dismiss_account_provisioner() {
- plan_for_modal_dialog(
- "AccountCreation",
- subtest_can_dismiss_account_provisioner
- );
- open_provisioner_window();
- wait_for_modal_dialog("AccountCreation");
-}
-
-/**
- * Subtest for test_can_dismiss_account_provisioner, that runs
- * once the modal dialog has opened. This function just clicks the
- * "I think I'll configure my account later" button, and then waits
- * for itself to close.
- */
-function subtest_can_dismiss_account_provisioner(w) {
- plan_for_window_close(w);
- // Click on the "I think I'll configure my account later" button.
- mc.click(new elib.Elem(w.window.document.querySelector(".close")));
-
- // Ensure that the window has closed.
- wait_for_window_close();
-}
-
-/**
- * Test that clicking on the "Skip this and use my existing email" button
- * sends us to the existing email account wizard.
- */
-function test_can_switch_to_existing_email_account_wizard() {
- plan_for_modal_dialog(
- "AccountCreation",
- subtest_can_switch_to_existing_email_account_wizard
- );
- open_provisioner_window();
- wait_for_modal_dialog("AccountCreation");
- // Ensure that the existing email account wizard opened.
- let wizard = wait_for_new_window("mail:autoconfig");
-
- // Then close the wizard
- close_window(wizard);
-}
-
-/**
- * Subtest for test_can_switch_to_existing_email_account_wizard. This
- * function simply clicks on the "Skip this and use my existing email"
- * button, and then waits for itself to close.
- */
-function subtest_can_switch_to_existing_email_account_wizard(w) {
- plan_for_window_close(w);
- plan_for_new_window("mail:autoconfig");
-
- // Click on the "Skip this and use my existing email" button
- mc.click(new elib.Elem(w.window.document.querySelector(".existing")));
-
- // Ensure that the Account Provisioner window closed
- wait_for_window_close();
-}
-
-/**
- * Test that clicking on the "Other languages" div causes account
- * providers with other languages to be displayed.
- */
-function test_can_display_providers_in_other_languages() {
- plan_for_modal_dialog(
- "AccountCreation",
- subtest_can_display_providers_in_other_languages
- );
- open_provisioner_window();
- wait_for_modal_dialog("AccountCreation");
-}
-
-/**
- * Subtest for test_can_display_providers_in_other_languages. This function
- * simply clicks on the div for displaying account providers in other
- * languages, and ensures that those other providers become visible.
- */
-function subtest_can_display_providers_in_other_languages(w) {
- wait_for_provider_list_loaded(w);
-
- // Check that the "Other languages" div is hidden
- wait_for_element_visible(w, "otherLangDesc");
- let otherLanguages = w.window.document.querySelectorAll(".otherLanguage");
- for (let element of otherLanguages) {
- assert_element_visible(new elib.Elem(element));
- }
- // Click on the "Other languages" div
- mc.click(w.eid("otherLangDesc"));
-
- wait_for_element_invisible(w, "otherLangDesc");
-}
-
-/**
- * Spawn the provisioner window by clicking on the menuitem,
- * then flip back and forth between that and the existing email
- * wizard, and then test to see if we can dismiss the provisioner.
- */
-function test_flip_flop_from_provisioner_menuitem() {
- plan_for_modal_dialog(
- "AccountCreation",
- subtest_flip_flop_from_provisioner_menuitem
- );
- plan_for_new_window("mail:autoconfig");
- open_provisioner_window();
- plan_for_new_window("mail:autoconfig");
- wait_for_modal_dialog("AccountCreation");
-
- const NUM_OF_FLIP_FLOPS = 3;
- let wizard;
-
- for (let i = 0; i < NUM_OF_FLIP_FLOPS; ++i) {
- wizard = wait_for_new_window("mail:autoconfig");
- plan_for_modal_dialog(
- "AccountCreation",
- subtest_flip_flop_from_provisioner_menuitem
- );
- plan_for_new_window("mail:autoconfig");
- plan_for_window_close(wizard);
- wizard.click(wizard.eid("provisioner_button"));
- wait_for_modal_dialog("AccountCreation");
- }
-
- wizard = wait_for_new_window("mail:autoconfig");
- plan_for_modal_dialog("AccountCreation", subtest_close_provisioner);
- wizard.click(wizard.eid("provisioner_button"));
- wait_for_modal_dialog("AccountCreation");
-}
-
-/**
- * This function is used by test_flip_flop_from_provisioner_menuitem to switch
- * back from the account provisioner to the wizard.
- */
-function subtest_flip_flop_from_provisioner_menuitem(w) {
- // We need to wait for the wizard to be closed, or else
- // it'll try to refocus when we click on the button to
- // open it.
- wait_for_the_wizard_to_be_closed(w);
- plan_for_window_close(w);
- mc.click(new elib.Elem(w.window.document.querySelector(".existing")));
- wait_for_window_close();
-}
-
-/**
- * This function is used by test_flip_flop_from_provisioner_menuitem to close
- * the provisioner.
- */
-function subtest_close_provisioner(w) {
- // Now make sure we can dismiss the provisioner.
- plan_for_window_close(w);
- // Click on the "I think I'll configure my account later" button.
- mc.click(new elib.Elem(w.window.document.querySelector(".close")));
- // Ensure that the window has closed.
- wait_for_window_close();
-}
-
-/**
- * Test that the name typed into the search field gets persisted after
- * doing a search, or choosing to go to the email setup wizard.
- */
-function test_persist_name_in_search_field() {
- plan_for_modal_dialog(
- "AccountCreation",
- subtest_persist_name_in_search_field
- );
- open_provisioner_window();
- wait_for_modal_dialog("AccountCreation");
- plan_for_modal_dialog(
- "AccountCreation",
- subtest_persist_name_in_search_field_part_2
- );
- open_provisioner_window();
- wait_for_modal_dialog("AccountCreation");
-}
-
-/**
- * Subtest used by test_persist_name_in_search_field. This function simply
- * puts a name into the search field, starts a search, and then dismisses
- * the window.
- */
-function subtest_persist_name_in_search_field(w) {
- wait_for_provider_list_loaded(w);
- wait_for_search_ready(w);
-
- // Type a name into the search field
- type_in_search_name(w, NAME);
-
- // Do a search
- w.click(w.eid("searchSubmit"));
- wait_for_search_results(w);
-
- plan_for_window_close(w);
- // Click on the "I think I'll configure my account later" button.
- mc.click(new elib.Elem(w.window.document.querySelector(".close")));
- wait_for_window_close();
-}
-
-/**
- * Subtest used by test_persist_name_in_search_field, the second time that
- * the account provisioner window is opened. This function simply checks to
- * ensure that the name inserted in subtest_persist_name_in_search_field has
- * indeed persisted.
- */
-function subtest_persist_name_in_search_field_part_2(w) {
- mc.waitFor(() => w.e("name").value == NAME);
-}
-
-/**
- * Test that names with HTML characters are escaped properly when displayed
- * back to the user.
- */
-function test_html_characters_and_ampersands() {
- plan_for_modal_dialog(
- "AccountCreation",
- subtest_html_characters_and_ampersands
- );
- open_provisioner_window();
- wait_for_modal_dialog("AccountCreation");
-}
-
-/**
- * Subtest used by test_html_characters_and_ampersands. This function puts
- * a name with HTML tags into the search input, does a search, and ensures
- * that the rendered name has escaped the HTML tags properly.
- */
-function subtest_html_characters_and_ampersands(w) {
- wait_for_provider_list_loaded(w);
- wait_for_search_ready(w);
-
- // Type a name with some HTML tags and an ampersand in there
- // to see if we can trip up account provisioner.
- const CLEVER_STRING =
- "<i>Hey, I'm ''clever &\"\" smart!<!-- Ain't I a stinkah? --></i>";
- type_in_search_name(w, CLEVER_STRING);
-
- // Do the search.
- w.click(w.eid("searchSubmit"));
-
- wait_for_search_results(w);
-
- let displayedName = w.e("FirstAndLastName").textContent;
-
- assert_not_equals(CLEVER_STRING, displayedName);
- // & should have been replaced with &, and the
- // greater than / less than characters with > and
- // < respectively.
- assert_true(
- displayedName.includes("&"),
- "Should have eliminated ampersands"
- );
- assert_true(
- displayedName.includes(">"),
- "Should have eliminated greater-than signs"
- );
- assert_true(
- displayedName.includes("<"),
- "Should have eliminated less-than signs"
- );
-}
-
-/**
- * Test that only the terms of service and privacy links for selected
- * providers are shown in the disclaimer.
- */
-function test_show_tos_privacy_links_for_selected_providers() {
- plan_for_modal_dialog(
- "AccountCreation",
- subtest_show_tos_privacy_links_for_selected_providers
- );
- open_provisioner_window();
- wait_for_modal_dialog("AccountCreation");
-}
-
-/**
- * Subtest used by test_show_tos_privacy_links_for_selected_providers. This
- * function selects and deselects a series of providers, and ensures that the
- * appropriate terms of service and privacy links are shown.
- */
-function subtest_show_tos_privacy_links_for_selected_providers(w) {
- wait_for_provider_list_loaded(w);
-
- // We should be showing the TOS and Privacy links for the selected
- // providers immediately after the providers have been loaded.
- // Those providers should be "foo" and "bar".
- assert_links_shown(w, [
- "http://www.example.com/foo-tos",
- "http://www.example.com/foo-privacy",
- "http://www.example.com/bar-tos",
- "http://www.example.com/bar-privacy",
- ]);
-
- assert_links_not_shown(w, [
- "http://www.example.com/French-tos",
- "http://www.example.com/French-privacy",
- ]);
-
- // Now click off one of those providers - we shouldn't be displaying
- // and links for that one now.
- let input = w.window.document.querySelector(
- 'input[type="checkbox"][value="foo"]'
- );
- w.click(new elib.Elem(input));
-
- assert_links_not_shown(w, [
- "http://www.example.com/foo-tos",
- "http://www.example.com/foo-privacy",
- ]);
-
- // Ensure that the "Other languages" div is visible
- wait_for_element_visible(w, "otherLangDesc");
- // Now show the providers from different locales...
- w.click(w.eid("otherLangDesc"));
- wait_for_element_invisible(w, "otherLangDesc");
-
- // And click on one of those providers...
- input = w.window.document.querySelector(
- 'input[type="checkbox"][value="French"]'
- );
- w.click(new elib.Elem(input));
- // We should be showing the French TOS / Privacy links, along
- // with those from the bar provider.
- assert_links_shown(w, [
- "http://www.example.com/French-tos",
- "http://www.example.com/French-privacy",
- "http://www.example.com/bar-tos",
- "http://www.example.com/bar-privacy",
- ]);
-
- // The foo provider should still have it's links hidden.
- assert_links_not_shown(w, [
- "http://www.example.com/foo-tos",
- "http://www.example.com/foo-privacy",
- ]);
-
- // Click on the German provider. It's links should now be
- // shown, along with the French and bar providers.
- input = w.window.document.querySelector(
- 'input[type="checkbox"][value="German"]'
- );
- w.click(new elib.Elem(input));
- assert_links_shown(w, [
- "http://www.example.com/French-tos",
- "http://www.example.com/French-privacy",
- "http://www.example.com/bar-tos",
- "http://www.example.com/bar-privacy",
- "http://www.example.com/German-tos",
- "http://www.example.com/German-privacy",
- ]);
-
- // And the foo links should still be hidden.
- assert_links_not_shown(w, [
- "http://www.example.com/foo-tos",
- "http://www.example.com/foo-privacy",
- ]);
-}
-
-/**
- * Test that if the search goes bad on the server-side, that we show an
- * error.
- */
-function test_shows_error_on_bad_suggest_from_name() {
- let original = Services.prefs.getCharPref(kSuggestFromNamePref);
- Services.prefs.setCharPref(kSuggestFromNamePref, url + "badSuggestFromName");
- plan_for_modal_dialog(
- "AccountCreation",
- subtest_shows_error_on_bad_suggest_from_name
- );
- open_provisioner_window();
- wait_for_modal_dialog("AccountCreation");
- Services.prefs.setCharPref(kSuggestFromNamePref, original);
-}
-
-/**
- * Subtest for test_shows_error_on_bad_suggest_from_name. This function does
- * a search, and then ensures that an error is displayed, since we got back
- * garbage from the server.
- */
-function subtest_shows_error_on_bad_suggest_from_name(w) {
- wait_for_provider_list_loaded(w);
- wait_for_search_ready(w);
-
- type_in_search_name(w, "Boston Low");
-
- // Do the search.
- w.click(w.eid("searchSubmit"));
-
- mc.waitFor(
- () => !w.window.document.querySelector("#notifications > .error").hidden
- );
-}
-
-/**
- * Test that if we get an empty result from the server after a search, that
- * we show an error message.
- */
-function test_shows_error_on_empty_suggest_from_name() {
- let original = Services.prefs.getCharPref(kSuggestFromNamePref);
- Services.prefs.setCharPref(
- kSuggestFromNamePref,
- url + "emptySuggestFromName"
- );
- plan_for_modal_dialog(
- "AccountCreation",
- subtest_shows_error_on_empty_suggest_from_name
- );
- open_provisioner_window();
- wait_for_modal_dialog("AccountCreation");
- Services.prefs.setCharPref(kSuggestFromNamePref, original);
-}
-
-/**
- * Subtest for test_shows_error_on_empty_suggest_from_name. This function does
- * a search, and then ensures that an error is displayed, since we got back
- * an empty result from the server.
- */
-function subtest_shows_error_on_empty_suggest_from_name(w) {
- wait_for_provider_list_loaded(w);
- wait_for_search_ready(w);
-
- type_in_search_name(w, "Maggie Robbins");
-
- // Do the search.
- w.click(w.eid("searchSubmit"));
-
- mc.waitFor(
- () => !w.window.document.querySelector("#notifications > .error").hidden
- );
-}
-
-/**
- * Tests that if a provider returns broken or erroneous XML back
- * to the user after account registration, that we log the error
- * in the error console.
- */
-function test_throws_console_error_on_corrupt_XML() {
- // Open the provisioner - once opened, let subtest_get_an_account run.
- get_to_order_form("corrupt@corrupt.invalid");
- let tab = mc.tabmail.currentTabInfo;
-
- // Record how many accounts we start with.
- gNumAccounts = nAccounts();
-
- gConsoleListener.reset();
- gConsoleListener.listenFor("Problem interpreting provider XML:");
-
- Services.console.registerListener(gConsoleListener);
-
- // Click the OK button to order the account.
- plan_for_modal_dialog("AccountCreation", close_dialog_immediately);
-
- let btn = tab.browser.contentWindow.document.querySelector(
- "input[value=Send]"
- );
- mc.click(new elib.Elem(btn));
- wait_for_modal_dialog("AccountCreation");
-
- gConsoleListener.wait();
-
- Services.console.unregisterListener(gConsoleListener);
-}
-
-/**
- * Test that if the providerList is invalid or broken JSON, that
- * we "go offline" and display an error message.
- */
-function test_broken_provider_list_goes_offline() {
- let original = Services.prefs.getCharPref(kProviderListPref);
- Services.prefs.setCharPref(kProviderListPref, url + "providerListBad");
-
- plan_for_modal_dialog(
- "AccountCreation",
- subtest_broken_provider_list_goes_offline
- );
- open_provisioner_window();
- wait_for_modal_dialog("AccountCreation");
- Services.prefs.setCharPref(kProviderListPref, original);
-}
-
-/**
- * Subtest for test_broken_provider_list_goes_offline. This function just
- * waits for the offline message to appear.
- */
-function subtest_broken_provider_list_goes_offline(w) {
- wait_to_be_offline(w);
-}
-
-/**
- * Test that if a provider has not included some of the required fields,
- * then they're not included as a potential provider for the user.
- */
-function test_incomplete_provider_not_displayed() {
- let original = Services.prefs.getCharPref(kProviderListPref);
- Services.prefs.setCharPref(kProviderListPref, url + "providerListIncomplete");
-
- plan_for_modal_dialog(
- "AccountCreation",
- subtest_incomplete_provider_not_displayed
- );
- open_provisioner_window();
- wait_for_modal_dialog("AccountCreation");
- Services.prefs.setCharPref(kProviderListPref, original);
-}
-
-/**
- * Subtest for test_incomplete_provider_not_displayed. This function just
- * ensures that the provider that didn't include all of the required fields
- * is not displayed.
- */
-function subtest_incomplete_provider_not_displayed(w) {
- wait_for_provider_list_loaded(w);
- // Make sure that the provider that didn't include the required fields
- // is not displayed.
- let input = w.window.document.querySelectorAll(
- 'input[type="checkbox"][value="corrupt"]'
- );
- assert_equals(
- 0,
- input.length,
- "The Corrupt provider should not have been displayed"
- );
-
- // And check to ensure that at least one other provider is displayed
- input = w.window.document.querySelectorAll(
- 'input[type="checkbox"][value="foo"]'
- );
- assert_equals(1, input.length, "The foo provider should have been displayed");
-}
-
-/**
- * Test that if the search text input is empty, or if no providers are selected,
- * that the search submit button is disabled.
- */
-function test_search_button_disabled_cases() {
- plan_for_modal_dialog(
- "AccountCreation",
- subtest_search_button_disabled_cases
- );
- open_provisioner_window();
- wait_for_modal_dialog("AccountCreation");
-}
-
-/**
- * Subtest for test_search_button_disabled_cases. This function ensures that
- * if the search input is empty, or if no providers are selected, then the
- * search submit button is disabled. If, on the other hand some providers
- * are selected AND some text is in the search input, then the search submit
- * button should be enabled.
- */
-function subtest_search_button_disabled_cases(w) {
- wait_for_provider_list_loaded(w);
- let searchInput = w.eid("name");
- // Case 1: Search input empty, some providers selected.
-
- // Empty any strings in the search input. Select all of the input with
- // Ctrl-A, and then hit backspace.
- searchInput.getNode().focus();
- w.keypress(null, "a", { accelKey: true });
- w.keypress(null, "VK_BACK_SPACE", {});
-
- // Make sure at least one provider is checked
- let input = w.window.document.querySelector('input[type="checkbox"]:checked');
- w.click(new elib.Elem(input));
- input = w.window.document.querySelector(
- 'input[type="checkbox"][value="foo"]'
- );
- w.click(new elib.Elem(input));
-
- // The search submit button should become disabled
- wait_for_element_enabled(w, w.e("searchSubmit"), false);
-
- // Case 2: Search input has text, some providers selected
-
- // Put something into the search input
- type_in_search_name(w, "Dexter Morgan");
-
- // We already have at least one provider checked from the last case, so
- // the search submit button should become enabled
- wait_for_element_enabled(w, w.e("searchSubmit"), true);
-
- // Case 3: Search input has text, no providers selected
- // Make sure no provider checkboxes are checked.
- let inputs = w.window.document.querySelectorAll(
- 'input[type="checkbox"]:checked'
- );
- for (input of inputs) {
- mc.click(new elib.Elem(input));
- }
-
- // The search submit button should now be disabled
- wait_for_element_enabled(w, w.e("searchSubmit"), false);
-
- // We'll turn on a single provider now to enable the search button,
- // so we can ensure that it actually *becomes* disabled for the next
- // case.
- input = w.window.document.querySelector(
- 'input[type="checkbox"][value="foo"]'
- );
- w.click(new elib.Elem(input));
- wait_for_element_enabled(w, w.e("searchSubmit"), true);
-
- // Case 4: Search input has no text, and no providers are
- // selected.
-
- // Clear out the search input
- w.keypress(null, "a", { accelKey: true });
- w.keypress(null, "VK_BACK_SPACE", {});
- input = w.window.document.querySelector('input[type="checkbox"]:checked');
- w.click(new elib.Elem(input));
-
- wait_for_element_enabled(w, w.e("searchSubmit"), false);
-}
-
-/**
- * Tests that when we pref off the Account Provisioner, the menuitem for it
- * becomes hidden, and the button to switch to it from the Existing Account
- * wizard also becomes hidden. Note that this doesn't test explicitly
- * whether or not the Account Provisioner spawns when there are no accounts.
- * The tests in this file will fail if the Account Provisioner does not spawn
- * with no accounts, and when preffed off, if the Account Provisioner does
- * spawn (which it shouldn't), the instrumentation Mozmill test should fail.
- */
-function test_can_pref_off_account_provisioner() {
- // First, we'll disable the account provisioner.
- Services.prefs.setBoolPref("mail.provider.enabled", false);
-
- // We'll use the Mozmill Menu API to grab the main menu...
- let mailMenuBar = mc.getMenu("#mail-menubar");
- let newMenuPopup = mc.eid("menu_NewPopup");
- let newMailAccountMenuitem = mc.eid("newMailAccountMenuItem");
-
- // First, we do some hackery to allow the "New" menupopup to respond to
- // events...
- let oldAllowEvents = newMenuPopup.getNode().allowevents;
- newMenuPopup.getNode().allowevents = true;
-
- // And then call open on the menu. This doesn't actually open the menu
- // on screen, but it simulates the act, and dynamically generated or
- // modified menuitems react accordingly. Simulating this helps us sidestep
- // weird platform issues.
- mailMenuBar.open();
-
- // Next, we'll ensure that the "Get a new mail account"
- // menuitem is no longer available
- mc.waitFor(function() {
- return mc.eid("newCreateEmailAccountMenuItem").getNode().hidden;
- }, "Timed out waiting for the Account Provisioner menuitem to be hidden");
-
- // Open up the Existing Account wizard
- plan_for_new_window("mail:autoconfig");
- mc.click(newMailAccountMenuitem);
-
- // Ensure that the existing email account wizard opened.
- let wizard = wait_for_new_window("mail:autoconfig");
-
- // And make sure the Get a New Account button is hidden.
- assert_true(wizard.eid("provisioner_button").getNode().hidden);
-
- // Alright, close the Wizard.
- plan_for_window_close(wizard);
- close_window(wizard);
- wait_for_window_close();
-
- // Ok, now pref the Account Provisioner back on
- Services.prefs.setBoolPref("mail.provider.enabled", true);
-
- // Re-open the menu to repopulate it.
- mailMenuBar.open();
-
- // Make sure that the "Get a new mail account" menuitem is NOT hidden.
- mc.waitFor(function() {
- return !mc.eid("newCreateEmailAccountMenuItem").getNode().hidden;
- }, "Timed out waiting for the Account Provisioner menuitem to appear");
-
- // Open up the Existing Account wizard
- plan_for_new_window("mail:autoconfig");
- mc.click(newMailAccountMenuitem);
-
- // Ensure that the existing email account wizard opened.
- wizard = wait_for_new_window("mail:autoconfig");
-
- // Make sure that the button to open the Account Provisioner dialog is
- // NOT hidden.
- assert_false(wizard.eid("provisioner_button").getNode().hidden);
-
- // Alright, close up.
- close_window(wizard);
-
- // And finally restore the menu to the way it was.
- newMenuPopup.getNode().allowevents = oldAllowEvents;
-}
-
-// We cannot control menus via Mozmill in OSX, so we'll skip this test.
-test_can_pref_off_account_provisioner.EXCLUDED_PLATFORMS = ["darwin"];
-
-/**
- * Tests that if we load a provider list that does not include providers in
- * other languages, then the "show me providers in other languages" link is
- * hidden.
- */
-function test_other_lang_link_hides() {
- let original = Services.prefs.getCharPref(kProviderListPref);
- Services.prefs.setCharPref(
- kProviderListPref,
- url + "providerListNoOtherLangs"
- );
-
- plan_for_modal_dialog("AccountCreation", subtest_other_lang_link_hides);
- open_provisioner_window();
- wait_for_modal_dialog("AccountCreation");
- Services.prefs.setCharPref(kProviderListPref, original);
-}
-
-/**
- * Subtest for test_other_lang_link_hides that just waits for the provider
- * list to be loaded, and then ensures that the "show me providers in other
- * languages" link is not visible.
- */
-function subtest_other_lang_link_hides(w) {
- wait_for_provider_list_loaded(w);
- wait_for_element_invisible(w, "otherLangDesc");
-}
-
-/**
- * Quickly get us to the default order form (registration.html) and return
- * when we're there.
- */
-function get_to_order_form(aAddress) {
- if (!aAddress) {
- aAddress = "green@example.com";
- }
-
- plan_for_modal_dialog("AccountCreation", function(aController) {
- sub_get_to_order_form(aController, aAddress);
- });
- open_provisioner_window();
- wait_for_modal_dialog("AccountCreation");
-
- // Once we're here, subtest_get_an_account has completed, and we're waiting
- // for a content tab to load for the account order form.
-
- // Make sure the page is loaded.
- wait_for_content_tab_load(undefined, function(aURL) {
- return aURL.host == "localhost";
- });
-}
-
-/**
- * Fills in the Account Provisioner dialog to get us to the order form.
- */
-function sub_get_to_order_form(aController, aAddress) {
- wait_for_provider_list_loaded(aController);
- wait_for_search_ready(aController);
-
- // Fill in some data
- type_in_search_name(aController, "Joe Nobody");
-
- aController.click(aController.eid("searchSubmit"));
- wait_for_search_results(aController);
-
- // Click on the requested address. This reveals the button with the price.
- let addressElts = [
- ...aController.window.document.querySelectorAll(".address"),
- ];
- let address = addressElts.filter(a => a.textContent == aAddress).shift();
- assert_true(!!address, "Couldn't find the requested address " + aAddress);
- aController.click(new elib.Elem(address));
- aController.waitFor(
- () =>
- aController.window.document.querySelectorAll(
- 'button.create:not([disabled="true"])'
- ).length > 0
- );
-
- // Pick the email address.
- plan_for_content_tab_load();
-
- // Clicking this button should close the modal dialog.
- let button = aController.window.document.querySelector(
- 'button.create[address="' + aAddress + '"]'
- );
- // mc.click() causes a failure here so click() is used for now.
- button.click();
-}
-
-/**
- * Helper function to be passed to plan_for_modal_dialog that closes the
- * Account Provisioner dialog immediately.
- */
-function close_dialog_immediately(aController) {
- plan_for_window_close(aController);
- mc.click(new elib.Elem(aController.window.document.querySelector(".close")));
- wait_for_window_close();
-}
-
-/**
- * Test that clicking on links in the order form open in the same account
- * provisioner tab.
- */
-function test_internal_link_opening_behaviour() {
- get_to_order_form();
-
- // Open the provisioner - once opened, let subtest_get_an_account run...
- let tab = mc.tabmail.currentTabInfo;
- let doc = tab.browser.contentWindow.document;
-
- // Click on the internal link.
- mc.click(new elib.Elem(doc.getElementById("internal")));
-
- // We should load the target page in the current tab browser.
- wait_for_browser_load(tab.browser, function(aURL) {
- return aURL.host == "localhost" && aURL.pathQueryRef == "/target.html";
- });
- // Now close the tab.
- mc.tabmail.closeTab(tab);
-}
-
-/**
- * Test that window.open in the order form opens in new content tabs.
- */
-function test_window_open_link_opening_behaviour() {
- get_to_order_form();
-
- let tab = mc.tabmail.currentTabInfo;
- let doc = tab.browser.contentWindow.document;
-
- // First, click on the Javascript link - this should open in a new content
- // tab and be focused.
- let newTabLink = doc.getElementById("newtab");
- open_content_tab_with_click(newTabLink, function(aURL) {
- return aURL.host == "localhost" && aURL.pathQueryRef == "/target.html";
- });
-
- // Close the new tab.
- let newTab = mc.tabmail.currentTabInfo;
- mc.tabmail.closeTab(newTab);
- mc.tabmail.closeTab(tab);
-}
-
-/**
- * Test that links with target="_blank" open in the default browser.
- */
-function test_external_link_opening_behaviour() {
- get_to_order_form();
-
- let tab = mc.tabmail.currentTabInfo;
- let doc = tab.browser.contentWindow.document;
-
- // Mock out the ExternalProtocolService.
- gMockExtProtSvcReg.register();
-
- let external = doc.getElementById("external");
- let targetHref = external.href;
- mc.click(new elib.Elem(external));
-
- mc.waitFor(
- () => gMockExtProtSvc.urlLoaded(targetHref),
- "Timed out waiting for the link " +
- targetHref +
- "to be " +
- "opened in the default browser."
- );
- gMockExtProtSvcReg.unregister();
- mc.tabmail.closeTab(tab);
-}
-
-/**
- * Test that if the provider returns XML that we can't turn into an account,
- * then we error out and go back to the Account Provisioner dialog.
- */
-function test_return_to_provisioner_on_error_XML() {
- const kOriginalTabNum = mc.tabmail.tabContainer.allTabs.length;
-
- get_to_order_form("error@error.invalid");
-
- let tab = mc.tabmail.currentTabInfo;
-
- plan_for_modal_dialog("AccountCreation", close_dialog_immediately);
-
- // Click the OK button to order the account.
- let btn = tab.browser.contentWindow.document.querySelector(
- "input[value=Send]"
- );
- mc.click(new elib.Elem(btn));
-
- wait_for_modal_dialog("AccountCreation");
-
- // We should be done executing the function defined in plan_for_modal_dialog
- // now, so the Account Provisioner dialog should be closed, and the order
- // form tab should have been closed.
- assert_equals(
- kOriginalTabNum,
- mc.tabmail.tabContainer.allTabs.length,
- "Timed out waiting for the order form tab to close."
- );
-}
-
-/**
- * Test that if we initiate a search, then the search input, the search button,
- * and all checkboxes should be disabled. The ability to close the window should
- * still be enabled though.
- */
-function test_disabled_fields_when_searching() {
- plan_for_modal_dialog(
- "AccountCreation",
- subtest_disabled_fields_when_searching
- );
- open_provisioner_window();
- wait_for_modal_dialog("AccountCreation");
-}
-
-/**
- * Subtest for test_disabled_fields_when_searching. Sets up a fake HTTP server
- * that slowly returns a search suggestion, and then checks to ensure all the
- * right fields are disabled (search input, search button, all check boxes).
- * We also make sure those fields are renabled once the test is completed.
- */
-function subtest_disabled_fields_when_searching(aController) {
- const kSuggestPath = "/slowSuggest";
- const kSearchMSeconds = 2000;
- let timer;
-
- function slow_results(aRequest, aResponse) {
- aResponse.processAsync();
- timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
- let result = [
- {
- product: "personalized_email",
- addresses: ["green@example.com", "green_llama@example.com"],
- succeeded: true,
- quote: "b28acb3c0a474d33af22",
- price: 0,
- provider: "bar",
- },
- ];
- let timerEvent = {
- notify(aTimer) {
- aResponse.setStatusLine(null, 200, "OK");
- aResponse.setHeader("Content-Type", "application/json");
- aResponse.write(JSON.stringify(result));
- aResponse.finish();
- },
- };
- timer.initWithCallback(
- timerEvent,
- kSearchMSeconds,
- Ci.nsITimer.TYPE_ONE_SHOT
- );
- }
-
- // Set up a mock HTTP server to serve up a super slow search...
- let server = new HttpServer();
- server.registerPathHandler(kSuggestPath, slow_results);
- server.start(kDefaultServerPort);
-
- // Now point our suggestFromName pref at that slow server.
- let originalSuggest = Services.prefs.getCharPref(kSuggestFromNamePref);
- Services.prefs.setCharPref(
- kSuggestFromNamePref,
- kDefaultServerRoot + kSuggestPath
- );
-
- wait_for_provider_list_loaded(aController);
- wait_for_search_ready(aController);
-
- let doc = aController.window.document;
- type_in_search_name(aController, "Fone Bone");
-
- aController.click(aController.eid("searchSubmit"));
-
- // Our slow search has started. We have kSearchMSeconds milliseconds before
- // the search completes. Plenty of time to check that the right things are
- // disabled.
- wait_for_element_enabled(aController, aController.e("searchSubmit"), false);
- wait_for_element_enabled(aController, aController.e("name"), false);
- let providerCheckboxes = doc.querySelectorAll(".providerCheckbox");
-
- for (let checkbox of providerCheckboxes) {
- wait_for_element_enabled(aController, checkbox, false);
- }
-
- // Check to ensure that the buttons for switching to the wizard and closing
- // the wizard are still enabled.
- wait_for_element_enabled(aController, doc.querySelector(".close"), true);
- wait_for_element_enabled(aController, doc.querySelector(".existing"), true);
-
- // Ok, wait for the results to come through...
- wait_for_search_results(aController);
-
- wait_for_element_enabled(aController, aController.e("searchSubmit"), true);
- wait_for_element_enabled(aController, aController.e("name"), true);
-
- for (let checkbox of providerCheckboxes) {
- wait_for_element_enabled(aController, checkbox, true);
- }
-
- // Ok, cleanup time. Put the old suggest URL back.
- Services.prefs.setCharPref(kSuggestFromNamePref, originalSuggest);
-
- // The fake HTTP server stops asynchronously, so let's kick off the stop
- // and wait for it to complete.
- let serverStopped = false;
- server.stop(function() {
- serverStopped = true;
- });
- aController.waitFor(
- () => serverStopped,
- "Timed out waiting for the fake server to stop."
- );
-
- close_dialog_immediately(aController);
-}
-
-/**
- * Tests that the search button is disabled if there is no initially
- * supported language for the user.
- */
-function test_search_button_disabled_if_no_lang_support() {
- // Set the user's supported language to something ridiculous (caching the
- // old one so we can put it back later).
- let originalReqLocales = Services.locale.requestedLocales;
- Services.locale.requestedLocales = ["foo"];
-
- plan_for_modal_dialog("AccountCreation", function(aController) {
- wait_for_provider_list_loaded(aController);
- // The search button should be disabled.
- wait_for_element_enabled(aController, aController.e("searchSubmit"), false);
- close_dialog_immediately(aController);
- });
-
- open_provisioner_window();
- wait_for_modal_dialog("AccountCreation");
-
- Services.locale.requestedLocales = originalReqLocales;
-}
-
-/**
- * Subtest used by several functions that checks to make sure that the
- * search button is disabled when the Account Provisioner dialog is opened,
- * in case there's no search input yet.
- */
-function subtest_search_button_enabled_state_on_init(aController) {
- wait_for_provider_list_loaded(aController);
-
- let enabled = !!aController.e("name").value;
-
- // The search button should be disabled if there's not search input.
- wait_for_element_enabled(aController, aController.e("searchSubmit"), enabled);
-
- close_dialog_immediately(aController);
-}
-
-/**
- * Test that if the providerList contains entries with supported languages
- * including "*", they are always displayed, even if the users locale pref
- * is not set to "*".
- */
-function test_provider_language_wildcard() {
- let originalReqLocales = Services.locale.requestedLocales;
- Services.locale.requestedLocales = ["foo-ba"];
-
- let original = Services.prefs.getCharPref(kProviderListPref);
- Services.prefs.setCharPref(kProviderListPref, url + "providerListWildcard");
-
- plan_for_modal_dialog("AccountCreation", subtest_provider_language_wildcard);
- open_provisioner_window();
- wait_for_modal_dialog("AccountCreation");
- Services.prefs.setCharPref(kProviderListPref, original);
- Services.locale.requestedLocales = originalReqLocales;
-}
-
-/**
- * Subtest used by test_provider_language_wildcard, ensures that the
- * "Universal" and "OtherUniversal" providers are displayed, but the French
- * and German ones are not.
- */
-function subtest_provider_language_wildcard(aController) {
- wait_for_provider_list_loaded(aController);
- // Check that the two universal providers are visible.
- wait_for_element_visible(aController, "universal-check");
- wait_for_element_visible(aController, "otherUniversal-check");
- // The French and German providers should not be visible.
- wait_for_element_invisible(aController, "french-check");
- wait_for_element_invisible(aController, "german-check");
- close_dialog_immediately(aController);
-}
-
-/**
- * Tests that the search button is disabled if we start up the Account
- * Provisioner, and we have no search in the input.
- */
-function test_search_button_disabled_if_no_query_on_init() {
- Services.prefs.setStringPref("mail.provider.realname", "");
- plan_for_modal_dialog(
- "AccountCreation",
- subtest_search_button_enabled_state_on_init
- );
- open_provisioner_window();
- wait_for_modal_dialog("AccountCreation");
-}
-
-/**
- * Test that if we try to open the Account Provisioner dialog when an
- * Account Provisioner tab is opened, that we focus the tab instead of opening
- * the dialog.
- */
-function test_get_new_account_focuses_existing_ap_tab() {
- get_to_order_form("green@example.com");
- let apTab = mc.tabmail.getTabInfoForCurrentOrFirstModeInstance(
- mc.tabmail.tabModes.accountProvisionerTab
- );
-
- // Switch back to the inbox tab.
- mc.tabmail.switchToTab(0);
-
- // Try to re-open the provisioner dialog
- open_provisioner_window();
-
- // If we got here, that means that we weren't blocked by a dialog
- // being opened, which is good.
- assert_selected_tab(apTab);
-
- // Now open up the wizard, and try opening the Account Provisioner from
- // there.
- plan_for_new_window("mail:autoconfig");
-
- // Open the wizard...
- mc.click(new elib.Elem(mc.menus.menu_File.menu_New.newMailAccountMenuItem));
- let wizard = wait_for_new_window("mail:autoconfig");
-
- // Click on the "Get a new Account" button in the wizard.
- wizard.click(wizard.eid("provisioner_button"));
-
- // If we got here, that means that we weren't blocked by a dialog
- // being opened, which is what we wanted..
- assert_selected_tab(apTab);
- mc.tabmail.closeTab(apTab);
-}
-
-/**
- * Test that some prices can be per-address, instead of per-provider.
- */
-function test_per_address_prices() {
- plan_for_modal_dialog("AccountCreation", subtest_per_address_prices);
- open_provisioner_window();
- wait_for_modal_dialog("AccountCreation");
-}
-
-/**
- * Subtest used by test_html_characters_and_ampersands. This function puts
- * a name with HTML tags into the search input, does a search, and ensures
- * that the rendered name has escaped the HTML tags properly.
- */
-function subtest_per_address_prices(w) {
- wait_for_provider_list_loaded(w);
- wait_for_search_ready(w);
-
- // Type a name with some HTML tags and an ampersand in there
- // to see if we can trip up account provisioner.
- type_in_search_name(w, "Joanna Finkelstein");
-
- // Do the search.
- mc.click(w.eid("searchSubmit"));
-
- wait_for_search_results(w);
-
- let prices = ["$20-$0 a year", "Free", "$20.00 a year"];
-
- // Check that the multi-provider has the default price.
- let providers = w.window.document.querySelectorAll(".provider");
- let price;
- let multi;
- for (let provider of providers) {
- if (provider.innerHTML == "multi") {
- multi = provider;
- price = provider.parentNode.querySelector(".price");
- break;
- }
- }
- assert_equals(price.innerHTML, prices[0].slice(0, 6));
-
- // Click on the multi provider. This reveals the buttons with the prices.
- mc.click(new elib.Elem(multi));
- mc.waitFor(
- () =>
- w.window.document.querySelectorAll('button.create:not([disabled="true"])')
- .length > 0
- );
-
- // For each button, make sure it has the correct price.
- let buttons = w.window.document.querySelectorAll(
- 'button.create:not([disabled="true"])'
- );
- let index = 0;
- for (let button of buttons) {
- // Emulate jquery's :visible selector
- if (button.offsetWidth == 0 && button.offsetHeight == 0) {
- continue;
- }
- assert_equals(button.innerHTML, prices[index]);
- index++;
- }
-}
deleted file mode 100644
--- a/mail/test/mozmill/notification/test-notification.js
+++ /dev/null
@@ -1,596 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-var {
- assert_false,
- assert_true,
- be_in_folder,
- create_folder,
- make_new_sets_in_folder,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var {
- plan_for_new_window,
- plan_for_window_close,
- wait_for_new_window,
- wait_for_window_close,
-} = ChromeUtils.import("resource://testing-common/mozmill/WindowHelpers.jsm");
-
-var { XPCOMUtils } = ChromeUtils.import(
- "resource://gre/modules/XPCOMUtils.jsm"
-);
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-// Our global folder variables...
-var gFolder = null;
-var gFolder2 = null;
-
-// An object to keep track of the boolean preferences we change, so that
-// we can put them back.
-var gOrigBoolPrefs = {};
-var gTotalOpenTime;
-
-// Used by make_gradually_newer_sets_in_folders
-var gMsgMinutes = 9000;
-
-// We'll use this mock alerts service to capture notification events
-var gMockAlertsService = {
- _doFail: false,
-
- QueryInterface: ChromeUtils.generateQI([Ci.nsIAlertsService]),
-
- showAlertNotification(
- imageUrl,
- title,
- text,
- textClickable,
- cookie,
- alertListener,
- name
- ) {
- // Setting the _doFail flag allows us to revert to the newmailalert.xhtml
- // notification
- if (this._doFail) {
- throw Cr.NS_ERROR_FAILURE;
- }
- this._didNotify = true;
- this._imageUrl = imageUrl;
- this._title = title;
- this._text = text;
- this._textClickable = textClickable;
- this._cookie = cookie;
- this._alertListener = alertListener;
- this._name = name;
-
- this._alertListener.observe(null, "alertfinished", this._cookie);
- },
-
- _didNotify: false,
- _imageUrl: null,
- _title: null,
- _text: null,
- _textClickable: null,
- _cookie: null,
- _alertListener: null,
- _name: null,
-
- _reset() {
- // Tell any listeners that we're through
- if (this._alertListener) {
- this._alertListener.observe(null, "alertfinished", this._cookie);
- }
-
- this._didNotify = false;
- this._imageUrl = null;
- this._title = null;
- this._text = null;
- this._textClickable = null;
- this._cookie = null;
- this._alertListener = null;
- this._name = null;
- },
-};
-
-var gMockAlertsServiceFactory = {
- createInstance(aOuter, aIID) {
- if (aOuter != null) {
- throw Cr.NS_ERROR_NO_AGGREGATION;
- }
-
- if (!aIID.equals(Ci.nsIAlertsService)) {
- throw Cr.NS_ERROR_NO_INTERFACE;
- }
-
- return gMockAlertsService;
- },
-};
-
-function setupModule(module) {
- // Register the mock alerts service
- Components.manager
- .QueryInterface(Ci.nsIComponentRegistrar)
- .registerFactory(
- Components.ID("{1bda6c33-b089-43df-a8fd-111907d6385a}"),
- "Mock Alerts Service",
- "@mozilla.org/system-alerts-service;1",
- gMockAlertsServiceFactory
- );
-
- // Ensure we have enabled new mail notifications
- remember_and_set_bool_pref("mail.biff.show_alert", true);
-
- // Ensure that system notifications are used (relevant for Linux only)
- if (
- Services.appinfo.OS == "Linux" ||
- "@mozilla.org/gio-service;1" in Cc ||
- "@mozilla.org/gnome-gconf-service;1" in Cc
- ) {
- remember_and_set_bool_pref("mail.biff.use_system_alert", true);
- }
-
- MailServices.accounts.localFoldersServer.performingBiff = true;
-
- // Create a second identity to check cross-account
- // notifications.
- var identity2 = MailServices.accounts.createIdentity();
- identity2.email = "new-account@foo.invalid";
-
- var server = MailServices.accounts.createIncomingServer(
- "nobody",
- "Test Local Folders",
- "pop3"
- );
-
- server.performingBiff = true;
-
- // Create the target folders
- gFolder = create_folder("My Folder");
- let localRoot = server.rootFolder.QueryInterface(Ci.nsIMsgLocalMailFolder);
- gFolder2 = localRoot.createLocalSubfolder("Another Folder");
-
- var account = MailServices.accounts.createAccount();
- account.incomingServer = server;
- account.addIdentity(identity2);
-}
-
-function teardownModule(module) {
- put_bool_prefs_back();
- if (Services.appinfo.OS != "Darwin") {
- Services.prefs.setIntPref("alerts.totalOpenTime", gTotalOpenTime);
- }
-}
-
-function setupTest(test) {
- gFolder.markAllMessagesRead(null);
- gMockAlertsService._reset();
- gMockAlertsService._doFail = false;
- gFolder.biffState = Ci.nsIMsgFolder.nsMsgBiffState_NoMail;
- gFolder2.biffState = Ci.nsIMsgFolder.nsMsgBiffState_NoMail;
-
- remember_and_set_bool_pref("mail.biff.alert.show_subject", true);
- remember_and_set_bool_pref("mail.biff.alert.show_sender", true);
- remember_and_set_bool_pref("mail.biff.alert.show_preview", true);
- if (Services.appinfo.OS != "Darwin") {
- gTotalOpenTime = Services.prefs.getIntPref("alerts.totalOpenTime");
- Services.prefs.setIntPref("alerts.totalOpenTime", 3000);
- }
-}
-
-function put_bool_prefs_back() {
- for (let prefString in gOrigBoolPrefs) {
- Services.prefs.setBoolPref(prefString, gOrigBoolPrefs[prefString]);
- }
-}
-
-function remember_and_set_bool_pref(aPrefString, aBoolValue) {
- if (!gOrigBoolPrefs[aPrefString]) {
- gOrigBoolPrefs[aPrefString] = Services.prefs.getBoolPref(aPrefString);
- }
-
- Services.prefs.setBoolPref(aPrefString, aBoolValue);
-}
-
-/* This function wraps up make_new_sets_in_folder, and takes the
- * same arguments. The point of this function is to ensure that
- * each sent message is slightly newer than the last. In this
- * case, each new message set will be sent one minute further
- * into the future than the last message set.
- */
-function make_gradually_newer_sets_in_folder(aFolder, aArgs) {
- gMsgMinutes -= 1;
- if (!aArgs.age) {
- for (let arg of aArgs) {
- arg.age = { minutes: gMsgMinutes };
- }
- }
- make_new_sets_in_folder(aFolder, aArgs);
-}
-
-/**
- * Test that we revert to newmailalert.xhtml if there is no system
- * notification service present.
- */
-function test_revert_to_newmailalert() {
- // Set up the gMockAlertsService so that it fails
- // to send a notification.
- gMockAlertsService._doFail = true;
-
- // We expect the newmailalert.xhtml window...
- plan_for_new_window("alert:alert");
- make_gradually_newer_sets_in_folder(gFolder, [{ count: 2 }]);
- let controller = wait_for_new_window("alert:alert");
- plan_for_window_close(controller);
- wait_for_window_close();
-}
-test_revert_to_newmailalert.EXCLUDED_PLATFORMS = ["winnt", "darwin"];
-
-/**
- * Test that receiving new mail causes a notification to appear
- */
-function test_new_mail_received_causes_notification() {
- make_gradually_newer_sets_in_folder(gFolder, [{ count: 1 }]);
- assert_true(
- gMockAlertsService._didNotify,
- "Did not show alert notification."
- );
-}
-test_new_mail_received_causes_notification.EXCLUDED_PLATFORMS = [
- "winnt",
- "darwin",
-];
-
-/**
- * Test that if notification shows, we don't show newmailalert.xhtml
- */
-function test_dont_show_newmailalert() {
- make_gradually_newer_sets_in_folder(gFolder, [{ count: 1 }]);
-
- // Wait for newmailalert.xhtml to show
- plan_for_new_window("alert:alert");
- try {
- wait_for_new_window("alert:alert");
- throw Error("Opened newmailalert.xhtml when we shouldn't have.");
- } catch (e) {
- // Correct behaviour - the window didn't show.
- }
-}
-test_new_mail_received_causes_notification.EXCLUDED_PLATFORMS = [
- "winnt",
- "darwin",
-];
-
-/**
- * Test that we notify, showing the oldest new, unread message received
- * since the last notification.
- */
-function test_show_oldest_new_unread_since_last_notification() {
- let notifyFirst = "This should notify first";
- assert_false(gMockAlertsService._didNotify, "Should not have notified yet.");
- make_gradually_newer_sets_in_folder(gFolder, [
- { count: 1, body: { body: notifyFirst } },
- ]);
- assert_true(gMockAlertsService._didNotify, "Should have notified.");
- assert_true(
- gMockAlertsService._text.includes(notifyFirst, 1),
- "Should have notified for the first message"
- );
-
- be_in_folder(gFolder);
- gFolder.biffState = Ci.nsIMsgFolder.nsMsgBiffState_NoMail;
- gMockAlertsService._reset();
-
- let notifySecond = "This should notify second";
- assert_false(gMockAlertsService._didNotify, "Should not have notified yet.");
- make_gradually_newer_sets_in_folder(gFolder, [
- { count: 1, body: { body: notifySecond } },
- ]);
- assert_true(gMockAlertsService._didNotify, "Should have notified.");
- assert_true(
- gMockAlertsService._text.includes(notifySecond, 1),
- "Should have notified for the second message"
- );
-}
-test_show_oldest_new_unread_since_last_notification.EXCLUDED_PLATFORMS = [
- "winnt",
- "darwin",
-];
-
-/**
- * Test that notifications work across different accounts.
- */
-function test_notification_works_across_accounts() {
- // Cause a notification in the first folder
- make_gradually_newer_sets_in_folder(gFolder, [{ count: 1 }]);
- assert_true(gMockAlertsService._didNotify, "Should have notified.");
-
- gMockAlertsService._reset();
- // We'll set the time for these messages to be slightly further
- // into the past. That way, test_notification_independent_across_accounts
- // has an opportunity to send slightly newer messages that are older than
- // the messages sent to gFolder.
- make_gradually_newer_sets_in_folder(gFolder2, [
- { count: 2, age: { minutes: gMsgMinutes + 20 } },
- ]);
- assert_true(gMockAlertsService._didNotify, "Should have notified.");
-}
-test_notification_works_across_accounts.EXCLUDED_PLATFORMS = [
- "winnt",
- "darwin",
-];
-
-/* Test that notification timestamps are independent from account
- * to account. This is for the scenario where we have two accounts, and
- * one has notified while the other is still updating. When the second
- * account completes, if it has new mail, it should notify, even if second
- * account's newest mail is older than the first account's newest mail.
- */
-function test_notifications_independent_across_accounts() {
- make_gradually_newer_sets_in_folder(gFolder, [{ count: 1 }]);
- assert_true(gMockAlertsService._didNotify, "Should have notified.");
-
- gMockAlertsService._reset();
- // Next, let's make some mail arrive in the second folder, but
- // let's have that mail be slightly older than the mail that
- // landed in the first folder. We should still notify.
- make_gradually_newer_sets_in_folder(gFolder2, [
- { count: 2, age: { minutes: gMsgMinutes + 10 } },
- ]);
- assert_true(gMockAlertsService._didNotify, "Should have notified.");
-}
-test_notifications_independent_across_accounts.EXCLUDED_PLATFORMS = [
- "winnt",
- "darwin",
-];
-
-/**
- * Test that we can show the message subject in the notification.
- */
-function test_show_subject() {
- let subject = "This should be displayed";
- make_gradually_newer_sets_in_folder(gFolder, [{ count: 1, subject }]);
- assert_true(gMockAlertsService._didNotify, "Should have notified");
- assert_true(
- gMockAlertsService._text.includes(subject),
- "Should have displayed the subject"
- );
-}
-test_show_subject.EXCLUDED_PLATFORMS = ["winnt", "darwin"];
-
-/**
- * Test that we can hide the message subject in the notification.
- */
-function test_hide_subject() {
- Services.prefs.setBoolPref("mail.biff.alert.show_subject", false);
- let subject = "This should not be displayed";
- make_gradually_newer_sets_in_folder(gFolder, [{ count: 1, subject }]);
- assert_true(gMockAlertsService._didNotify, "Should have notified");
- assert_true(
- !gMockAlertsService._text.includes(subject),
- "Should not have displayed the subject"
- );
-}
-test_hide_subject.EXCLUDED_PLATFORMS = ["winnt", "darwin"];
-
-/**
- * Test that we can show just the message sender in the notification.
- */
-function test_show_only_subject() {
- Services.prefs.setBoolPref("mail.biff.alert.show_preview", false);
- Services.prefs.setBoolPref("mail.biff.alert.show_sender", false);
- Services.prefs.setBoolPref("mail.biff.alert.show_subject", true);
-
- let sender = ["John Cleese", "john@cleese.invalid"];
- let subject = "This should not be displayed";
- let messageBody = "My message preview";
-
- make_gradually_newer_sets_in_folder(gFolder, [
- { count: 1, from: sender, subject, body: { body: messageBody } },
- ]);
- assert_true(gMockAlertsService._didNotify, "Should have notified");
- assert_true(
- gMockAlertsService._text.includes(subject),
- "Should have displayed the subject"
- );
- assert_true(
- !gMockAlertsService._text.includes(messageBody),
- "Should not have displayed the preview"
- );
- assert_true(
- !gMockAlertsService._text.includes(sender[0]),
- "Should not have displayed the sender"
- );
-}
-test_show_only_subject.EXCLUDED_PLATFORMS = ["winnt", "darwin"];
-
-/**
- * Test that we can show the message sender in the notification.
- */
-function test_show_sender() {
- let sender = ["John Cleese", "john@cleese.invalid"];
- make_gradually_newer_sets_in_folder(gFolder, [{ count: 1, from: sender }]);
- assert_true(gMockAlertsService._didNotify, "Should have notified");
- assert_true(
- gMockAlertsService._text.includes(sender[0]),
- "Should have displayed the sender"
- );
-}
-test_show_sender.EXCLUDED_PLATFORMS = ["winnt", "darwin"];
-
-/**
- * Test that we can hide the message sender in the notification.
- */
-function test_hide_sender() {
- Services.prefs.setBoolPref("mail.biff.alert.show_sender", false);
- let sender = ["John Cleese", "john@cleese.invalid"];
- make_gradually_newer_sets_in_folder(gFolder, [{ count: 1, from: sender }]);
- assert_true(gMockAlertsService._didNotify, "Should have notified");
- assert_true(
- !gMockAlertsService._text.includes(sender[0]),
- "Should not have displayed the sender"
- );
-}
-test_hide_sender.EXCLUDED_PLATFORMS = ["winnt", "darwin"];
-
-/**
- * Test that we can show just the message sender in the notification.
- */
-function test_show_only_sender() {
- Services.prefs.setBoolPref("mail.biff.alert.show_preview", false);
- Services.prefs.setBoolPref("mail.biff.alert.show_sender", true);
- Services.prefs.setBoolPref("mail.biff.alert.show_subject", false);
-
- let sender = ["John Cleese", "john@cleese.invalid"];
- let subject = "This should not be displayed";
- let messageBody = "My message preview";
-
- make_gradually_newer_sets_in_folder(gFolder, [
- { count: 1, from: sender, subject, body: { body: messageBody } },
- ]);
- assert_true(gMockAlertsService._didNotify, "Should have notified");
- assert_true(
- gMockAlertsService._text.includes(sender[0]),
- "Should have displayed the sender"
- );
- assert_true(
- !gMockAlertsService._text.includes(messageBody),
- "Should not have displayed the preview"
- );
- assert_true(
- !gMockAlertsService._text.includes(subject),
- "Should not have displayed the subject"
- );
-}
-test_show_only_sender.EXCLUDED_PLATFORMS = ["winnt", "darwin"];
-
-/**
- * Test that we can show the message preview in the notification.
- */
-function test_show_preview() {
- Services.prefs.setBoolPref("mail.biff.alert.show_preview", true);
- let messageBody = "My message preview";
- make_gradually_newer_sets_in_folder(gFolder, [
- { count: 1, body: { body: messageBody } },
- ]);
- assert_true(gMockAlertsService._didNotify, "Should have notified");
- assert_true(
- gMockAlertsService._text.includes(messageBody),
- "Should have displayed the preview"
- );
-}
-test_show_preview.EXCLUDED_PLATFORMS = ["winnt", "darwin"];
-
-/**
- * Test that we can hide the message preview in the notification.
- */
-function test_hide_preview() {
- Services.prefs.setBoolPref("mail.biff.alert.show_preview", false);
- let messageBody = "My message preview";
- make_gradually_newer_sets_in_folder(gFolder, [
- { count: 1, body: { body: messageBody } },
- ]);
- assert_true(gMockAlertsService._didNotify, "Should have notified");
- assert_true(
- !gMockAlertsService._text.includes(messageBody),
- "Should not have displayed the preview"
- );
-}
-test_hide_preview.EXCLUDED_PLATFORMS = ["winnt", "darwin"];
-
-/**
- * Test that we can show justthe message preview in the notification.
- */
-function test_show_only_preview() {
- Services.prefs.setBoolPref("mail.biff.alert.show_preview", true);
- Services.prefs.setBoolPref("mail.biff.alert.show_sender", false);
- Services.prefs.setBoolPref("mail.biff.alert.show_subject", false);
-
- let sender = ["John Cleese", "john@cleese.invalid"];
- let subject = "This should not be displayed";
- let messageBody = "My message preview";
- make_gradually_newer_sets_in_folder(gFolder, [
- { count: 1, from: sender, subject, body: { body: messageBody } },
- ]);
- assert_true(gMockAlertsService._didNotify, "Should have notified");
- assert_true(
- gMockAlertsService._text.includes(messageBody),
- "Should have displayed the preview: " + gMockAlertsService._text
- );
- assert_true(
- !gMockAlertsService._text.includes(sender[0]),
- "Should not have displayed the sender"
- );
- assert_true(
- !gMockAlertsService._text.includes(subject),
- "Should not have displayed the subject"
- );
-}
-test_show_only_preview.EXCLUDED_PLATFORMS = ["winnt", "darwin"];
-
-/**
- * Test that we can receive notifications even when the biff state of
- * the folder has not been changed.
- */
-function test_still_notify_with_unchanged_biff() {
- // For now, we'll make sure that if we receive 10 pieces
- // of email, one after the other, we'll be notified for all
- // (assuming of course that the notifications have a chance
- // to close in between arrivals - we don't want a queue of
- // notifications to go through).
- const HOW_MUCH_MAIL = 10;
-
- assert_false(gMockAlertsService._didNotify, "Should have notified.");
-
- for (let i = 0; i < HOW_MUCH_MAIL; i++) {
- make_gradually_newer_sets_in_folder(gFolder, [{ count: 1 }]);
- assert_true(gMockAlertsService._didNotify, "Should have notified.");
- gMockAlertsService._reset();
- }
-}
-test_still_notify_with_unchanged_biff.EXCLUDED_PLATFORMS = ["winnt", "darwin"];
-
-/**
- * Test that we don't receive notifications for Draft, Queue, SentMail,
- * Templates or Junk folders.
- */
-function test_no_notification_for_uninteresting_folders() {
- var someFolder = create_folder("Uninteresting Folder");
- var uninterestingFlags = [
- Ci.nsMsgFolderFlags.Drafts,
- Ci.nsMsgFolderFlags.Queue,
- Ci.nsMsgFolderFlags.SentMail,
- Ci.nsMsgFolderFlags.Templates,
- Ci.nsMsgFolderFlags.Junk,
- Ci.nsMsgFolderFlags.Archive,
- ];
-
- for (let i = 0; i < uninterestingFlags.length; i++) {
- someFolder.flags = uninterestingFlags[i];
- make_gradually_newer_sets_in_folder(someFolder, [{ count: 1 }]);
- assert_false(gMockAlertsService._didNotify, "Showed alert notification.");
- }
-
- // However, we want to ensure that Inboxes *always* notify, even
- // if they possess the flags we consider uninteresting.
- someFolder.flags = Ci.nsMsgFolderFlags.Inbox;
-
- for (let i = 0; i < uninterestingFlags.length; i++) {
- someFolder.flags |= uninterestingFlags[i];
- make_gradually_newer_sets_in_folder(someFolder, [{ count: 1 }]);
- assert_true(
- gMockAlertsService._didNotify,
- "Did not show alert notification."
- );
- someFolder.flags = someFolder.flags & ~uninterestingFlags[i];
- }
-}
-test_no_notification_for_uninteresting_folders.EXCLUDED_PLATFORMS = [
- "winnt",
- "darwin",
-];
deleted file mode 100644
--- a/mail/test/mozmill/override-main-menu-collapse/test-override-mainmenu-collapse.js
+++ /dev/null
@@ -1,52 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests that the main menu will NOT be collapsed by default if Thunderbird
- * starts with no accounts created, and mail.main_menu.collapse_by_default set
- * to false.
- */
-
-"use strict";
-
-var { assert_false, mc } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { close_window, wait_for_existing_window } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-function test_main_menu_not_collapsed() {
- // Due to random oranges on slower machines, we need to ensure that startup
- // is complete before running this test.
- let done = false;
- let observer = {
- observe(aSubject, aTopic, aData) {
- if (aTopic == "mail-startup-done") {
- done = true;
- }
- },
- };
- Services.obs.addObserver(observer, "mail-startup-done");
-
- // Since no accounts were set up, and the account provisoner was disabled
- // in prefs.js, the wizard will show up. Find it, and close it. This will
- // cause mail-startup-done to eventually be fired.
- let wizard = wait_for_existing_window("mail:autoconfig");
- close_window(wizard);
-
- // Spin the event loop until mail-startup-done is fired.
- mc.waitFor(() => done);
-
- let mainMenu = mc.e("mail-toolbar-menubar2");
- assert_false(
- mainMenu.hasAttribute("autohide"),
- "The main menu should not have the autohide attribute."
- );
-
- Services.obs.removeObserver(observer, "mail-startup-done");
-}
-test_main_menu_not_collapsed.EXCLUDED_PLATFORMS = ["Darwin"];
deleted file mode 100644
--- a/mail/test/mozmill/override-main-menu-collapse/wrapper.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-# For these tests, we need to disable the account provisioner, or
-# else it will spawn immediately and block before we have a chance to run
-# any Mozmill tests.
-
-import os
-import shutil
-
-# We don't want any accounts for these tests.
-NO_ACCOUNTS = True
-# Do not force enable main menu bar, we'll set our own value in prefs.js.
-DEFAULT_MENUBAR = True
-
-PREFS = {
- "mail.provider.enabled": False,
- "mail.main_menu.collapse_by_default": False,
-}
deleted file mode 100644
--- a/mail/test/mozmill/pref-window/test-font-chooser.js
+++ /dev/null
@@ -1,297 +0,0 @@
-/* -*- Mode: JavaScript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test various things about the font chooser window, including
- * - whether if the font defined in font.name.<style>.<language> is not present
- * on the computer, we fall back to displaying what's in
- * font.name-list.<style>.<language>.
- */
-
-"use strict";
-
-var { content_tab_e, content_tab_eid } = ChromeUtils.import(
- "resource://testing-common/mozmill/ContentTabHelpers.jsm"
-);
-var { mc } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { close_pref_tab, open_pref_tab } = ChromeUtils.import(
- "resource://testing-common/mozmill/PrefTabHelpers.jsm"
-);
-var { wait_for_frame_load } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var { AppConstants } = ChromeUtils.import(
- "resource://gre/modules/AppConstants.jsm"
-);
-var { Preferences } = ChromeUtils.import(
- "resource://gre/modules/Preferences.jsm"
-);
-
-var gFontEnumerator;
-var gTodayPane;
-
-// We'll test with Western. Unicode has issues on Windows (bug 550443).
-const kLanguage = "x-western";
-
-// A list of fonts present on the computer for each font type.
-var gRealFontLists = {};
-
-// A list of font types to consider
-const kFontTypes = ["serif", "sans-serif", "monospace"];
-
-function setupModule(module) {
- let finished = false;
- buildFontList().then(() => (finished = true), Cu.reportError);
- mc.waitFor(
- () => finished,
- "Timeout waiting for font enumeration to complete."
- );
-
- // Hide Lightning's Today pane as it obscures buttons in preferences in the
- // small TB window our tests run in.
- gTodayPane = mc.e("today-pane-panel");
- if (gTodayPane) {
- if (!gTodayPane.collapsed) {
- mc.keypress(null, "VK_F11", {});
- } else {
- gTodayPane = null;
- }
- }
-}
-
-async function buildFontList() {
- gFontEnumerator = Cc["@mozilla.org/gfx/fontenumerator;1"].createInstance(
- Ci.nsIFontEnumerator
- );
- for (let fontType of kFontTypes) {
- gRealFontLists[fontType] = await gFontEnumerator.EnumerateFontsAsync(
- kLanguage,
- fontType
- );
- if (gRealFontLists[fontType].length == 0) {
- throw new Error(
- "No fonts found for language " +
- kLanguage +
- " and font type " +
- fontType +
- "."
- );
- }
- }
-}
-
-function assert_fonts_equal(aDescription, aExpected, aActual, aPrefix = false) {
- if (
- !(
- (!aPrefix && aExpected == aActual) ||
- (aPrefix && aActual.startsWith(aExpected))
- )
- ) {
- throw new Error(
- "The " +
- aDescription +
- " font should be '" +
- aExpected +
- "', but " +
- (aActual.length == 0
- ? "nothing is actually selected."
- : "is actually: " + aActual + ".")
- );
- }
-}
-
-/**
- * Verify that the given fonts are displayed in the font chooser. This opens the
- * pref window to the display pane and checks that, then opens the font chooser
- * and checks that too.
- */
-function _verify_fonts_displayed(aDefaults, aSerif, aSansSerif, aMonospace) {
- // Bring up the preferences window.
- let prefTab = open_pref_tab("paneGeneral");
-
- let isSansDefault =
- Services.prefs.getCharPref("font.default." + kLanguage) == "sans-serif";
- let displayPaneExpected = isSansDefault ? aSansSerif : aSerif;
- let displayPaneActual = content_tab_e(prefTab, "defaultFont");
- mc.waitFor(
- () => displayPaneActual.itemCount > 0,
- "No font names were populated in the font picker."
- );
- assert_fonts_equal(
- "display pane",
- displayPaneExpected,
- displayPaneActual.value
- );
-
- // Now open the advanced dialog.
- mc.click(content_tab_eid(prefTab, "advancedFonts"));
- let fontc = wait_for_frame_load(
- prefTab.browser.contentDocument
- .getElementById("dialogOverlay-0")
- .querySelector("browser"),
- "chrome://messenger/content/preferences/fonts.xhtml"
- );
-
- // The font pickers are populated async so we need to wait for it.
- for (let fontElemId of ["serif", "sans-serif", "monospace"]) {
- fontc.waitFor(
- () => fontc.e(fontElemId).label != "",
- "Timeout waiting for font picker '" + fontElemId + "' to populate."
- );
- }
-
- if (!aDefaults) {
- assert_fonts_equal("serif", aSerif, fontc.e("serif").value);
- assert_fonts_equal("sans-serif", aSansSerif, fontc.e("sans-serif").value);
- assert_fonts_equal("monospace", aMonospace, fontc.e("monospace").value);
- } else if (AppConstants.platform == "linux") {
- // When default fonts are displayed in the menulist, there is no value set,
- // only the label, in the form "Default (font name)".
-
- // On Linux the prefs we set contained only the generic font names,
- // like 'serif', but here a specific font name will be shown, but it is
- // system-dependent what it will be. So we just check for the 'Default'
- // prefix.
- assert_fonts_equal("serif", `Default (`, fontc.e("serif").label, true);
- assert_fonts_equal(
- "sans-serif",
- `Default (`,
- fontc.e("sans-serif").label,
- true
- );
- assert_fonts_equal(
- "monospace",
- `Default (`,
- fontc.e("monospace").label,
- true
- );
- } else {
- assert_fonts_equal("serif", `Default (${aSerif})`, fontc.e("serif").label);
- assert_fonts_equal(
- "sans-serif",
- `Default (${aSansSerif})`,
- fontc.e("sans-serif").label
- );
- assert_fonts_equal(
- "monospace",
- `Default (${aMonospace})`,
- fontc.e("monospace").label
- );
- }
-
- close_pref_tab(prefTab);
-}
-
-/**
- * Test that for a particular language, whatever's in
- * font.name.<type>.<language> is displayed in the font chooser (if it is
- * present on the computer).
- */
-function test_font_name_displayed() {
- Services.prefs.setCharPref("font.language.group", kLanguage);
-
- // Pick the first font for each font type and set it.
- let expected = {};
- for (let [fontType, fontList] of Object.entries(gRealFontLists)) {
- // Work around bug 698238 (on Windows, Courier is returned by the enumerator but
- // substituted with Courier New) by getting the standard (substituted) family
- // name for each font.
- let standardFamily = gFontEnumerator.getStandardFamilyName(fontList[0]);
- Services.prefs.setCharPref(
- "font.name." + fontType + "." + kLanguage,
- standardFamily
- );
- expected[fontType] = standardFamily;
- }
-
- let fontTypes = kFontTypes.map(fontType => expected[fontType]);
- _verify_fonts_displayed(false, ...fontTypes);
-}
-
-// Fonts definitely not present on a computer -- we simply use UUIDs. These
-// should be kept in sync with the ones in *-prefs.js.
-const kFakeFonts = {
- serif: "bc7e8c62-0634-467f-a029-fe6abcdf1582",
- "sans-serif": "419129aa-43b7-40c4-b554-83d99b504b89",
- monospace: "348df6e5-e874-4d21-ad4b-359b530a33b7",
-};
-
-/**
- * Test that for a particular language, if font.name.<type>.<language> is not
- * present on the computer, we fall back to displaying what's in
- * font.name-list.<type>.<language>.
- */
-function test_font_name_not_present() {
- Services.prefs.setCharPref("font.language.group", kLanguage);
-
- // The fonts we're expecting to see selected in the font chooser for
- // test_font_name_not_present.
- let expected = {};
- for (let [fontType, fakeFont] of Object.entries(kFakeFonts)) {
- // Look at the font.name-list. We need to verify that the first font is the
- // fake one, and that the second one is present on the user's computer.
- let listPref = "font.name-list." + fontType + "." + kLanguage;
- let fontList = Services.prefs.getCharPref(listPref);
- let fonts = fontList.split(",").map(font => font.trim());
- if (fonts.length != 2) {
- throw new Error(
- listPref +
- " should have exactly two fonts, but it is '" +
- fontList +
- "'."
- );
- }
-
- if (fonts[0] != fakeFont) {
- throw new Error(
- "The first font in " +
- listPref +
- " should be '" +
- fakeFont +
- "', but is actually: " +
- fonts[0] +
- "."
- );
- }
-
- if (!gRealFontLists[fontType].includes(fonts[1])) {
- throw new Error(
- "The second font in " +
- listPref +
- " (" +
- fonts[1] +
- ") should be present on this computer, but isn't."
- );
- }
- expected[fontType] = fonts[1];
-
- // Set font.name to be a nonsense name that shouldn't exist.
- // font.name-list is handled by wrapper.py.
- Services.prefs.setCharPref(
- "font.name." + fontType + "." + kLanguage,
- fakeFont
- );
- }
-
- let fontTypes = kFontTypes.map(fontType => expected[fontType]);
- _verify_fonts_displayed(true, ...fontTypes);
-}
-
-function teardownTest() {
- // nsIPrefBranch.resetBranch() is not implemented in M-C, so we can't use
- // Services.prefs.resetBranch().
- Preferences.resetBranch("font.name.");
-}
-
-function teardownModule() {
- Services.prefs.clearUserPref("font.language.group");
- if (gTodayPane && gTodayPane.collapsed) {
- mc.keypress(null, "VK_F11", {});
- }
-}
deleted file mode 100644
--- a/mail/test/mozmill/pref-window/wrapper.py
+++ /dev/null
@@ -1,32 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-# For test-font-chooser.js we need a few default prefs -- this module does that.
-
-import sys
-
-# Default preferences used for test-font-chooser.js. The UUIDs here
-# should be kept in sync with kFakeFonts in test-font-chooser.js.
-
-if sys.platform == "win32":
- PREFS = {
- "font.name-list.serif.x-western": "bc7e8c62-0634-467f-a029-fe6abcdf1582, Times New Roman",
- "font.name-list.sans-serif.x-western": "419129aa-43b7-40c4-b554-83d99b504b89, Arial",
- "font.name-list.monospace.x-western": "348df6e5-e874-4d21-ad4b-359b530a33b7, Courier New",
- }
-
-elif sys.platform == "darwin":
- PREFS = {
- "font.name-list.serif.x-western": "bc7e8c62-0634-467f-a029-fe6abcdf1582, Times",
- "font.name-list.sans-serif.x-western": "419129aa-43b7-40c4-b554-83d99b504b89, Helvetica",
- "font.name-list.monospace.x-western": "348df6e5-e874-4d21-ad4b-359b530a33b7, Courier",
- }
-
-else:
- # Fallback to Linux prefs -- we're assuming that they're other unixes.
- PREFS = {
- "font.name-list.serif.x-western": "bc7e8c62-0634-467f-a029-fe6abcdf1582, serif",
- "font.name-list.sans-serif.x-western": "419129aa-43b7-40c4-b554-83d99b504b89, sans-serif",
- "font.name-list.monospace.x-western": "348df6e5-e874-4d21-ad4b-359b530a33b7, monospace",
- }
deleted file mode 100644
--- a/mail/test/mozmill/quick-filter-bar/test-display-issues.js
+++ /dev/null
@@ -1,203 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test things of a visual nature.
- *
- * Note: this test requires a screen resolution of 1280 x 1024 which is standard on
- * the unit test machines (see also testing/machine-configuration.json).
- */
-
-"use strict";
-
-var { collapse_panes } = ChromeUtils.import(
- "resource://testing-common/mozmill/DOMHelpers.jsm"
-);
-var {
- assert_default_window_size,
- assert_pane_layout,
- assert_true,
- be_in_folder,
- create_folder,
- gDefaultWindowHeight,
- gDefaultWindowWidth,
- kClassicMailLayout,
- kVerticalMailLayout,
- mark_action,
- mc,
- open_folder_in_new_window,
- restore_default_window_size,
- set_pane_layout,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var {
- assert_quick_filter_bar_visible,
- clear_constraints,
- toggle_quick_filter_bar,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/QuickFilterBarHelpers.jsm"
-);
-var { close_window, resize_to } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var folder;
-var setUnstarred, setStarred;
-var gOriginalPaneWidth;
-
-var gEnlargedWindowWidth = 1260;
-var gShrunkenWindowWidth = 600;
-
-var gTodayPane;
-
-function setupModule(module) {
- folder = create_folder("QuickFilterBarDisplayIssues");
- be_in_folder(folder);
-
- // Let's check window dimensions so we can enlarge from them.
- restore_default_window_size();
- assert_true(
- gEnlargedWindowWidth > gDefaultWindowWidth,
- "Main window too large for the test logic"
- );
-
- // Store folder pane width that we will change temporarily.
- let folderPaneBox = mc.e("folderPaneBox");
- gOriginalPaneWidth = folderPaneBox.width;
-
- // Hide Lightning's Today pane as it takes up too much room in the
- // small TB window our tests run in.
- gTodayPane = mc.e("today-pane-panel");
- if (gTodayPane) {
- if (!gTodayPane.collapsed) {
- mc.keypress(null, "VK_F11", {});
- } else {
- gTodayPane = null;
- }
- }
-}
-
-/**
- * When the window gets too narrow the collapsible button labels need to get
- * gone. Then they need to come back when we get large enough again.
- *
- * Because the mozmill window sizing is weird and confusing, we force our size
- * in both cases but do save/restore around our test.
- */
-function test_buttons_collapse_and_expand() {
- assert_quick_filter_bar_visible(true); // precondition
-
- let qfbCollapsy = mc.e("quick-filter-bar-collapsible-buttons");
- let qfbExemplarButton = mc.e("qfb-unread"); // (arbitrary labeled button)
- let qfbExemplarLabel = qfbExemplarButton.querySelector(".toolbarbutton-text");
-
- function logState(aWhen) {
- mark_action("test", "log_window_state", [
- aWhen,
- "location:",
- mc.window.screenX,
- mc.window.screenY,
- "dims:",
- mc.window.outerWidth,
- mc.window.outerHeight,
- "Collapsy bar width:",
- qfbCollapsy.clientWidth,
- "shrunk?",
- qfbCollapsy.getAttribute("shrink"),
- ]);
- }
-
- function assertCollapsed() {
- // The bar should be shrunken and the button should be the same size as its
- // image!
- if (qfbCollapsy.getAttribute("shrink") != "true") {
- throw new Error("The collapsy bar should be shrunk!");
- }
- if (qfbExemplarLabel.clientWidth != 0) {
- throw new Error("The exemplar label should be collapsed!");
- }
- }
- function assertExpanded() {
- // The bar should not be shrunken and the button should be smaller than its
- // label!
- if (qfbCollapsy.hasAttribute("shrink")) {
- throw new Error("The collapsy bar should not be shrunk!");
- }
- if (qfbExemplarLabel.clientWidth == 0) {
- throw new Error("The exemplar label should not be collapsed!");
- }
- }
-
- logState("entry");
-
- // -- GIANT!
- resize_to(mc, gEnlargedWindowWidth, gDefaultWindowHeight);
- // Right, so resizeTo caps us at the display size limit, so we may end up
- // smaller than we want. So let's turn off the folder pane too.
- collapse_panes(mc.e("folderpane_splitter"), true);
- logState("giant");
- assertExpanded();
- // NOTE! 1260 is actually not much above what's needed to get the
- // expanded qfb.
-
- // -- tiny.
- collapse_panes(mc.e("folderpane_splitter"), false);
- resize_to(mc, gShrunkenWindowWidth, gDefaultWindowHeight);
- logState("tiny");
- assertCollapsed();
-
- // -- GIANT again!
- resize_to(mc, gEnlargedWindowWidth, gDefaultWindowHeight);
- collapse_panes(mc.e("folderpane_splitter"), true);
- logState("giant again!");
- assertExpanded();
-}
-
-function test_buttons_collapse_and_expand_on_spawn_in_vertical_mode() {
- // Assume we're in classic layout to start - since this is where we'll
- // reset to once we're done.
- assert_pane_layout(kClassicMailLayout);
-
- // Put us in vertical mode
- set_pane_layout(kVerticalMailLayout);
-
- // Make our window nice and wide.
- resize_to(mc, gEnlargedWindowWidth, gDefaultWindowHeight);
-
- // Now expand the folder pane to cause the QFB buttons to shrink
- let folderPaneBox = mc.e("folderPaneBox");
- folderPaneBox.width = 600;
-
- // Now spawn a new 3pane...
- let mc2 = open_folder_in_new_window(folder);
- let qfb = mc2.e("quick-filter-bar-collapsible-buttons");
- mc2.waitFor(
- () => qfb.getAttribute("shrink") == "true",
- "New 3pane should have had a collapsed QFB"
- );
- close_window(mc2);
-
- set_pane_layout(kClassicMailLayout);
-}
-
-function teardownTest() {
- clear_constraints();
- // make it visible if it's not
- if (mc.e("quick-filter-bar").collapsed) {
- toggle_quick_filter_bar();
- }
-}
-
-function teardownModule() {
- // Restore the window to original layout.
- restore_default_window_size();
- collapse_panes(mc.e("folderpane_splitter"), false);
- let folderPaneBox = mc.e("folderPaneBox");
- folderPaneBox.width = gOriginalPaneWidth;
-
- if (gTodayPane && gTodayPane.collapsed) {
- mc.keypress(null, "VK_F11", {});
- }
-}
deleted file mode 100644
--- a/mail/test/mozmill/quick-filter-bar/test-filter-logic.js
+++ /dev/null
@@ -1,430 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Verify that we are constructing the filters that we expect and that they
- * are hooked up to the right buttons.
- */
-
-"use strict";
-
-var {
- assert_messages_in_view,
- assert_messages_not_in_view,
- be_in_folder,
- create_folder,
- delete_message_set,
- make_new_sets_in_folder,
- mc,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var {
- assert_quick_filter_bar_visible,
- assert_results_label_count,
- assert_text_constraints_checked,
- clear_constraints,
- set_filter_text,
- toggle_boolean_constraints,
- toggle_quick_filter_bar,
- toggle_tag_constraints,
- toggle_tag_mode,
- toggle_text_constraints,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/QuickFilterBarHelpers.jsm"
-);
-
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-function test_filter_unread() {
- let folder = create_folder("QuickFilterBarFilterUnread");
- let [unread, read] = make_new_sets_in_folder(folder, [
- { count: 1 },
- { count: 1 },
- ]);
- read.setRead(true);
-
- be_in_folder(folder);
- toggle_boolean_constraints("unread");
- assert_messages_in_view(unread);
-}
-
-function test_filter_starred() {
- let folder = create_folder("QuickFilterBarFilterStarred");
- let [, starred] = make_new_sets_in_folder(folder, [
- { count: 1 },
- { count: 1 },
- ]);
- starred.setStarred(true);
-
- be_in_folder(folder);
- toggle_boolean_constraints("starred");
- assert_messages_in_view(starred);
-}
-
-function test_filter_simple_intersection_unread_and_starred() {
- let folder = create_folder("QuickFilterBarFilterUnreadAndStarred");
- let [, readUnstarred, unreadStarred, readStarred] = make_new_sets_in_folder(
- folder,
- [{ count: 1 }, { count: 1 }, { count: 1 }, { count: 1 }]
- );
- readUnstarred.setRead(true);
- unreadStarred.setStarred(true);
- readStarred.setRead(true);
- readStarred.setStarred(true);
-
- be_in_folder(folder);
- toggle_boolean_constraints("unread", "starred");
-
- assert_messages_in_view(unreadStarred);
-}
-
-function test_filter_attachments() {
- let attachSetDef = {
- count: 1,
- attachments: [
- {
- filename: "foo.png",
- contentType: "image/png",
- encoding: "base64",
- charset: null,
- body: "YWJj\n",
- format: null,
- },
- ],
- };
- let noAttachSetDef = {
- count: 1,
- };
-
- let folder = create_folder("QuickFilterBarFilterAttachments");
- let [, setAttach] = make_new_sets_in_folder(folder, [
- noAttachSetDef,
- attachSetDef,
- ]);
-
- be_in_folder(folder);
- toggle_boolean_constraints("attachments");
-
- assert_messages_in_view(setAttach);
-}
-
-/**
- * Create a card for the given e-mail address, adding it to the first address
- * book we can find.
- */
-function add_email_to_address_book(aEmailAddr) {
- let card = Cc["@mozilla.org/addressbook/cardproperty;1"].createInstance(
- Ci.nsIAbCard
- );
- card.primaryEmail = aEmailAddr;
-
- let enumerator = MailServices.ab.directories;
- while (enumerator.hasMoreElements()) {
- let addrbook = enumerator.getNext();
- if (addrbook instanceof Ci.nsIAbDirectory) {
- addrbook.addCard(card);
- return;
- }
- }
-
- throw new Error("Unable to find any suitable address book.");
-}
-
-function test_filter_in_address_book() {
- let bookSetDef = {
- from: ["Qbert Q Qbington", "q@q.invalid"],
- count: 1,
- };
- add_email_to_address_book(bookSetDef.from[1]);
- let folder = create_folder("MesssageFilterBarInAddressBook");
- let [setBook] = make_new_sets_in_folder(folder, [bookSetDef, { count: 1 }]);
- be_in_folder(folder);
- toggle_boolean_constraints("addrbook");
- assert_messages_in_view(setBook);
-}
-
-function test_filter_tags() {
- let folder = create_folder("QuickFilterBarTags");
- const tagA = "$label1",
- tagB = "$label2",
- tagC = "$label3";
- let [setNoTag, setTagA, setTagB, setTagAB, setTagC] = make_new_sets_in_folder(
- folder,
- [{ count: 1 }, { count: 1 }, { count: 1 }, { count: 1 }, { count: 1 }]
- );
- setTagA.addTag(tagA);
- setTagB.addTag(tagB);
- setTagAB.addTag(tagA);
- setTagAB.addTag(tagB);
- setTagC.addTag(tagC);
-
- be_in_folder(folder);
- toggle_boolean_constraints("tags"); // must have a tag
- assert_messages_in_view([setTagA, setTagB, setTagAB, setTagC]);
-
- toggle_tag_constraints(tagA); // must have tag A
- assert_messages_in_view([setTagA, setTagAB]);
-
- toggle_tag_constraints(tagB);
- // mode is OR by default -> must have tag A or tag B
- assert_messages_in_view([setTagA, setTagB, setTagAB]);
-
- toggle_tag_mode();
- // mode is now AND -> must have tag A and tag B
- assert_messages_in_view([setTagAB]);
-
- toggle_tag_constraints(tagA); // must have tag B
- assert_messages_in_view([setTagB, setTagAB]);
-
- toggle_tag_constraints(tagB); // have have a tag
- assert_messages_in_view([setTagA, setTagB, setTagAB, setTagC]);
-
- toggle_boolean_constraints("tags"); // no constraints
- assert_messages_in_view([setNoTag, setTagA, setTagB, setTagAB, setTagC]);
-
- // If we have filtered to a specific tag and we disable the tag filter
- // entirely, make sure that when we turn it back on we are just back to "any
- // tag".
- toggle_boolean_constraints("tags");
- toggle_tag_constraints(tagC);
- assert_messages_in_view(setTagC);
-
- toggle_boolean_constraints("tags"); // no constraints
- toggle_boolean_constraints("tags"); // should be any tag (not tagC!)
- assert_messages_in_view([setTagA, setTagB, setTagAB, setTagC]);
-}
-
-function test_filter_text_single_word_and_predicates() {
- let folder = create_folder("QuickFilterBarTextSingleWord");
- let whoFoo = ["zabba", "foo@madeup.invalid"];
- let [
- ,
- setSenderFoo,
- setRecipientsFoo,
- setSubjectFoo,
- setBodyFoo,
- ] = make_new_sets_in_folder(folder, [
- { count: 1 },
- { count: 1, from: whoFoo },
- { count: 1, to: [whoFoo] },
- { count: 1, subject: "foo" },
- { count: 1, body: { body: "foo" } },
- ]);
- be_in_folder(folder);
-
- // by default, sender/recipients/subject are selected
- assert_text_constraints_checked("sender", "recipients", "subject");
-
- // con defaults, por favor
- set_filter_text("foo");
- assert_messages_in_view([setSenderFoo, setRecipientsFoo, setSubjectFoo]);
- // note: we sequence the changes in the list so there is always at least one
- // dude selected. selecting down to nothing has potential UI implications
- // we don't want this test to get affected by.
- // sender only
- toggle_text_constraints("recipients", "subject");
- assert_messages_in_view(setSenderFoo);
- // recipients only
- toggle_text_constraints("recipients", "sender");
- assert_messages_in_view(setRecipientsFoo);
- // subject only
- toggle_text_constraints("subject", "recipients");
- assert_messages_in_view(setSubjectFoo);
- // body only
- toggle_text_constraints("body", "subject");
- assert_messages_in_view(setBodyFoo);
- // everybody
- toggle_text_constraints("sender", "recipients", "subject");
- assert_messages_in_view([
- setSenderFoo,
- setRecipientsFoo,
- setSubjectFoo,
- setBodyFoo,
- ]);
-
- // sanity check non-matching
- set_filter_text("notgonnamatchevercauseisayso");
- assert_messages_in_view([]);
- // disable body, still should get nothing
- toggle_text_constraints("body");
- assert_messages_in_view([]);
-
- // (we are leaving with the defaults once again active)
- assert_text_constraints_checked("sender", "recipients", "subject");
-}
-
-/**
- * Verify that the multi-word logic is actually splitting the words into
- * different terms and that the terms can match in different predicates.
- * This means that given "foo bar" we should be able to match "bar foo" in
- * a subject and "foo" in the sender and "bar" in the recipient. And that
- * constitutes sufficient positive coverage, although we also want to make
- * sure that just a single term match is insufficient.
- */
-function test_filter_text_multi_word() {
- let folder = create_folder("QuickFilterBarTextMultiWord");
-
- let whoFoo = ["foo", "zabba@madeup.invalid"];
- let whoBar = ["zabba", "bar@madeup.invalid"];
- let [, setPeepMatch, setSubjReverse] = make_new_sets_in_folder(folder, [
- { count: 1 },
- { count: 1, from: whoFoo, to: [whoBar] },
- { count: 1, subject: "bar foo" },
- { count: 1, from: whoFoo },
- ]);
- be_in_folder(folder);
-
- // (precondition)
- assert_text_constraints_checked("sender", "recipients", "subject");
-
- set_filter_text("foo bar");
- assert_messages_in_view([setPeepMatch, setSubjReverse]);
-}
-
-/**
- * Verify that the quickfilter bar has OR functionality using
- * | (Pipe character) - Bug 586131
- */
-function test_filter_or_operator() {
- let folder = create_folder("QuickFilterBarOrOperator");
-
- let whoFoo = ["foo", "zabba@madeup.invalid"];
- let whoBar = ["zabba", "bar@madeup.invalid"];
- let whoTest = ["test", "test@madeup.invalid"];
- let [
- setInert,
- setSenderFoo,
- setToBar,
- ,
- ,
- setSubject3,
- setMail1,
- ] = make_new_sets_in_folder(folder, [
- { count: 1 },
- { count: 1, from: whoFoo },
- { count: 1, to: [whoBar] },
- { count: 1, subject: "foo bar" },
- { count: 1, subject: "bar test" },
- { count: 1, subject: "test" },
- { count: 1, to: [whoTest], subject: "logic" },
- { count: 1, from: whoFoo, to: [whoBar], subject: "test" },
- ]);
- be_in_folder(folder);
-
- assert_text_constraints_checked("sender", "recipients", "subject");
- set_filter_text("foo | bar");
- assert_messages_not_in_view([setInert, setSubject3, setMail1]);
-
- set_filter_text("test | bar");
- assert_messages_not_in_view([setInert, setSenderFoo]);
-
- set_filter_text("foo | test");
- assert_messages_not_in_view([setInert, setToBar]);
-
- // consists of leading and trailing spaces and tab character.
- set_filter_text("test | foo bar");
- assert_messages_not_in_view([
- setInert,
- setSenderFoo,
- setToBar,
- setSubject3,
- setMail1,
- ]);
-
- set_filter_text("test | foo bar |logic");
- assert_messages_not_in_view([setInert, setSenderFoo, setToBar, setSubject3]);
-}
-
-/**
- * Make sure that when dropping all constraints on toggle off or changing
- * folders that we persist/propagate the state of the
- * sender/recipients/subject/body toggle buttons.
- */
-function test_filter_text_constraints_propagate() {
- let whoFoo = ["foo", "zabba@madeup.invalid"];
- let whoBar = ["zabba", "bar@madeup.invalid"];
-
- let folderOne = create_folder("QuickFilterBarTextPropagate1");
- let [setSubjFoo, setWhoFoo] = make_new_sets_in_folder(folderOne, [
- { count: 1, subject: "foo" },
- { count: 1, from: whoFoo },
- ]);
- let folderTwo = create_folder("QuickFilterBarTextPropagate2");
- let [, setWhoBar] = make_new_sets_in_folder(folderTwo, [
- { count: 1, subject: "bar" },
- { count: 1, from: whoBar },
- ]);
-
- be_in_folder(folderOne);
- set_filter_text("foo");
- // (precondition)
- assert_text_constraints_checked("sender", "recipients", "subject");
- assert_messages_in_view([setSubjFoo, setWhoFoo]);
-
- // -- drop subject, close bar to reset, make sure it sticks
- toggle_text_constraints("subject");
- assert_messages_in_view([setWhoFoo]);
-
- toggle_quick_filter_bar();
- toggle_quick_filter_bar();
-
- set_filter_text("foo");
- assert_messages_in_view([setWhoFoo]);
- assert_text_constraints_checked("sender", "recipients");
-
- // -- now change folders and make sure the settings stick
- be_in_folder(folderTwo);
- set_filter_text("bar");
- assert_messages_in_view([setWhoBar]);
- assert_text_constraints_checked("sender", "recipients");
-}
-
-/**
- * Here is what the results label does:
- * - No filter active: results label is not visible.
- * - Filter active, messages: it says the number of messages.
- * - Filter active, no messages: it says there are no messages.
- *
- * Additional nuances:
- * - The count needs to update as the user deletes messages or what not.
- */
-function test_results_label() {
- let folder = create_folder("QuickFilterBarResultsLabel");
- let [setImmortal, setMortal, setGoldfish] = make_new_sets_in_folder(folder, [
- { count: 1 },
- { count: 1 },
- { count: 1 },
- ]);
-
- be_in_folder(folder);
-
- // no filter, the label should not be visible
- if (mc.e("qfb-results-label").visible) {
- throw new Error("results label should not be visible, yo! mad impropah!");
- }
-
- toggle_boolean_constraints("unread");
- assert_messages_in_view([setImmortal, setMortal, setGoldfish]);
- assert_results_label_count(3);
-
- delete_message_set(setGoldfish);
- assert_results_label_count(2);
-
- delete_message_set(setMortal);
- assert_results_label_count(1);
-
- delete_message_set(setImmortal);
- assert_results_label_count(0);
-}
-
-function teardownTest() {
- clear_constraints();
- // make it visible if it's not
- if (mc.e("quick-filter-bar").collapsed) {
- toggle_quick_filter_bar();
- }
-}
deleted file mode 100644
--- a/mail/test/mozmill/quick-filter-bar/test-keyboard-interface.js
+++ /dev/null
@@ -1,190 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests keyboard stuff that doesn't fall under some other test's heading.
- * Namely, control-shift-k toggling the bar into existence happens in
- * test-toggle-bar.js, but we test that repeatedly hitting control-shift-k
- * selects the text entered in the quick filter bar.
- */
-
-"use strict";
-
-var {
- be_in_folder,
- create_folder,
- make_new_sets_in_folder,
- mc,
- select_click_row,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var {
- assert_constraints_expressed,
- assert_filter_text,
- assert_quick_filter_bar_visible,
- clear_constraints,
- set_filter_text,
- toggle_boolean_constraints,
- toggle_quick_filter_bar,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/QuickFilterBarHelpers.jsm"
-);
-
-var folder;
-
-function setupModule(module) {
- folder = create_folder("QuickFilterBarKeyboardInterface");
- // we need a message so we can select it so we can find in message
- make_new_sets_in_folder(folder, [{ count: 1 }]);
- be_in_folder(folder);
-}
-
-/**
- * The rules for pressing escape:
- * - If there are any applied constraints:
- * - If there is a 'most recent' constraint, it is relaxed and the 'most
- * recent' field gets cleared, so that if escape gets hit again...
- * - If there is no 'most recent' constraint, all constraints are cleared.
- * - If there are no applied constraints, we close the filter bar.
- *
- * We test these rules two ways:
- * 1) With the focus in the thread pane.
- * 2) With our focus in our text-box.
- */
-function test_escape_rules() {
- assert_quick_filter_bar_visible(true); // (precondition)
-
- // the common logic for each bit...
- function legwork() {
- // apply two...
- toggle_boolean_constraints("unread", "starred", "addrbook");
- assert_constraints_expressed({
- unread: true,
- starred: true,
- addrbook: true,
- });
- assert_quick_filter_bar_visible(true);
-
- // hit escape, should clear addrbook
- mc.keypress(null, "VK_ESCAPE", {});
- assert_quick_filter_bar_visible(true);
- assert_constraints_expressed({ unread: true, starred: true });
-
- // hit escape, should clear both remaining ones
- mc.keypress(null, "VK_ESCAPE", {});
- assert_quick_filter_bar_visible(true);
- assert_constraints_expressed({});
-
- // hit escape, bar should disappear
- mc.keypress(null, "VK_ESCAPE", {});
- assert_quick_filter_bar_visible(false);
-
- // bring the bar back for the next dude
- toggle_quick_filter_bar();
- }
-
- // 1) focus in the thread pane
- mc.e("threadTree").focus();
- legwork();
-
- // 2) focus in the text box
- mc.e("qfb-qs-textbox").focus();
- legwork();
-
- // 3) focus in the text box and pretend to type stuff...
- mc.e("qfb-qs-textbox").focus();
- set_filter_text("qxqxqxqx");
-
- // Escape should clear the text constraint but the bar should still be
- // visible. The trick here is that escape is clearing the text widget
- // and is not falling through to the cmd_popQuickFilterBarStack case so we
- // end up with a situation where the _lastFilterAttr is the textbox but the
- // textbox does not actually have any active filter.
- mc.keypress(null, "VK_ESCAPE", {});
- assert_quick_filter_bar_visible(true);
- assert_constraints_expressed({});
- assert_filter_text("");
-
- // Next escape should close the box
- mc.keypress(null, "VK_ESCAPE", {});
- assert_quick_filter_bar_visible(false);
-}
-
-/**
- * It's fairly important that the gloda search widget eats escape when people
- * press escape in there. Because gloda is disabled by default, we need to
- * viciously uncollapse it ourselves and then cleanup afterwards...
- */
-function test_escape_does_not_reach_us_from_gloda_search() {
- let glodaSearchWidget = mc.e("searchInput");
- try {
- // uncollapse and focus the gloda search widget
- glodaSearchWidget.removeAttribute("hidden");
- glodaSearchWidget.focus();
-
- mc.keypress(null, "VK_ESCAPE", {});
-
- assert_quick_filter_bar_visible(true);
- } finally {
- glodaSearchWidget.setAttribute("hidden", "hidden");
- }
-}
-
-/**
- * Control-shift-k expands the quick filter bar when it's collapsed. When
- * already expanded, it focuses the text box and selects its text.
- */
-function test_control_shift_k_shows_quick_filter_bar() {
- let dispatcha = mc.window.document.commandDispatcher;
- let qfbTextbox = mc.e("qfb-qs-textbox");
-
- // focus explicitly on the thread pane so we know where the focus is.
- mc.e("threadTree").focus();
- // select a message so we can find in message
- select_click_row(0);
-
- // hit control-shift-k to get in the quick filter box
- mc.keypress(null, "k", { accelKey: true, shiftKey: true });
- if (dispatcha.focusedElement != qfbTextbox.inputField) {
- throw new Error("control-shift-k did not focus quick filter textbox");
- }
-
- set_filter_text("search string");
-
- // hit control-shift-k to select the text in the quick filter box
- mc.keypress(null, "k", { accelKey: true, shiftKey: true });
- if (dispatcha.focusedElement != qfbTextbox.inputField) {
- throw new Error(
- "second control-shift-k did not keep focus on filter textbox"
- );
- }
- if (
- qfbTextbox.inputField.selectionStart != 0 ||
- qfbTextbox.inputField.selectionEnd != qfbTextbox.inputField.textLength
- ) {
- throw new Error(
- "second control-shift-k did not select text in filter textbox"
- );
- }
-
- // hit escape and make sure the text is cleared, but the quick filter bar is
- // still open.
- mc.keypress(null, "VK_ESCAPE", {});
- assert_quick_filter_bar_visible(true);
- assert_filter_text("");
-
- // hit escape one more time and make sure we finally collapsed the quick
- // filter bar.
- mc.keypress(null, "VK_ESCAPE", {});
- assert_quick_filter_bar_visible(false);
-}
-
-function teardownTest() {
- clear_constraints();
- // make it visible if it's not
- if (mc.e("quick-filter-bar").collapsed) {
- toggle_quick_filter_bar();
- }
-}
deleted file mode 100644
--- a/mail/test/mozmill/quick-filter-bar/test-sticky-filter-logic.js
+++ /dev/null
@@ -1,151 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Sticky logic only needs to test the general sticky logic plus any filters
- * with custom propagateState implementations (currently: tags, text filter.)
- */
-
-"use strict";
-
-var {
- assert_messages_in_view,
- be_in_folder,
- close_tab,
- create_folder,
- make_new_sets_in_folder,
- mc,
- open_folder_in_new_tab,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var {
- assert_constraints_expressed,
- assert_filter_text,
- assert_tag_constraints_visible,
- clear_constraints,
- set_filter_text,
- toggle_boolean_constraints,
- toggle_quick_filter_bar,
- toggle_tag_constraints,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/QuickFilterBarHelpers.jsm"
-);
-
-/**
- * Persist the current settings through folder change and inherit into a new tab.
- */
-function test_sticky_basics() {
- let folderOne = create_folder("QuickFilterBarStickyBasics1");
- let [unreadOne, readOne] = make_new_sets_in_folder(folderOne, [
- { count: 1 },
- { count: 1 },
- ]);
- readOne.setRead(true);
-
- let folderTwo = create_folder("QuickFilterBarStickyBasics2");
- let [unreadTwo, readTwo] = make_new_sets_in_folder(folderTwo, [
- { count: 1 },
- { count: 1 },
- ]);
- readTwo.setRead(true);
-
- // -- setup
- be_in_folder(folderOne);
- toggle_boolean_constraints("sticky", "unread");
- assert_messages_in_view(unreadOne);
-
- // -- change folders
- be_in_folder(folderTwo);
- assert_constraints_expressed({ sticky: true, unread: true });
- assert_messages_in_view(unreadTwo);
-
- // -- inherit into a new folder
- let tabB = open_folder_in_new_tab(folderOne);
- assert_constraints_expressed({ sticky: true, unread: true });
- assert_messages_in_view(unreadOne);
-
- close_tab(tabB);
-}
-
-/**
- * The semantics of sticky tags are not obvious; there were decisions involved:
- * - If the user has the tag facet enabled but not explicitly filtered on
- * specific tags then we propagate just "true" to cause the faceting to
- * run in the new folder. In other words, the list of displayed tags should
- * change.
- * - If the user has filtered on specific tags, then we do and must propagate
- * the list of tags.
- *
- * We only need to do folder changes from here on out since the logic is
- * identical (and tested to be identical in |test_sticky_basics|).
- */
-function test_sticky_tags() {
- let folderOne = create_folder("QuickFilterBarStickyTags1");
- let folderTwo = create_folder("QuickFilterBarStickyTags2");
- const tagA = "$label1",
- tagB = "$label2",
- tagC = "$label3";
- let [, setTagA1, setTagB1] = make_new_sets_in_folder(folderOne, [
- { count: 1 },
- { count: 1 },
- { count: 1 },
- ]);
- let [, setTagA2, setTagC2] = make_new_sets_in_folder(folderTwo, [
- { count: 1 },
- { count: 1 },
- { count: 1 },
- ]);
- setTagA1.addTag(tagA);
- setTagB1.addTag(tagB);
- setTagA2.addTag(tagA);
- setTagC2.addTag(tagC);
-
- be_in_folder(folderOne);
- toggle_boolean_constraints("sticky", "tags");
- assert_tag_constraints_visible(tagA, tagB);
- assert_messages_in_view([setTagA1, setTagB1]);
-
- // -- re-facet when we change folders since constraint was just true
- be_in_folder(folderTwo);
- assert_tag_constraints_visible(tagA, tagC);
- assert_messages_in_view([setTagA2, setTagC2]);
-
- // -- do not re-facet since tag A was selected
- toggle_tag_constraints(tagA);
- be_in_folder(folderOne);
- assert_tag_constraints_visible(tagA, tagC);
- assert_messages_in_view([setTagA1]);
-
- // -- if we turn off sticky, make sure that things clear when we change
- // folders. (we had a bug with this before.)
- toggle_boolean_constraints("sticky");
- be_in_folder(folderTwo);
- assert_constraints_expressed({});
-}
-
-/**
- * All we are testing propagating is the text value; the text states are always
- * propagated and that is tested in test-filter-logic.js by
- * |test_filter_text_constraints_propagate|.
- */
-function test_sticky_text() {
- let folderOne = create_folder("QuickFilterBarStickyText1");
- let folderTwo = create_folder("QuickFilterBarStickyText2");
-
- be_in_folder(folderOne);
- toggle_boolean_constraints("sticky");
- set_filter_text("foo");
-
- be_in_folder(folderTwo);
- assert_filter_text("foo");
-}
-
-function teardownTest() {
- clear_constraints();
- // make it visible if it's not
- if (mc.e("quick-filter-bar").collapsed) {
- toggle_quick_filter_bar();
- }
-}
deleted file mode 100644
--- a/mail/test/mozmill/quick-filter-bar/test-toggle-bar.js
+++ /dev/null
@@ -1,103 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test that the message filter bar toggles into and out of existence and
- * states are updated as appropriate.
- */
-
-"use strict";
-
-var {
- assert_messages_in_view,
- be_in_folder,
- create_folder,
- make_new_sets_in_folder,
- mc,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var {
- assert_constraints_expressed,
- assert_quick_filter_bar_visible,
- assert_quick_filter_button_enabled,
- clear_constraints,
- toggle_boolean_constraints,
- toggle_quick_filter_bar,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/QuickFilterBarHelpers.jsm"
-);
-
-var folder;
-var setUnstarred, setStarred;
-
-function setupModule(module) {
- folder = create_folder("QuickFilterBarToggleBar");
- [setUnstarred, setStarred] = make_new_sets_in_folder(folder, [
- { count: 1 },
- { count: 1 },
- ]);
- setStarred.setStarred(true);
-}
-
-function test_hidden_on_account_central() {
- be_in_folder(folder.rootFolder);
- assert_quick_filter_button_enabled(false);
- assert_quick_filter_bar_visible(false);
-}
-
-function test_visible_by_default() {
- be_in_folder(folder);
- assert_quick_filter_button_enabled(true);
- assert_quick_filter_bar_visible(true);
-}
-
-function test_direct_toggle() {
- assert_quick_filter_bar_visible(true);
- toggle_quick_filter_bar();
- assert_quick_filter_bar_visible(false);
- toggle_quick_filter_bar();
- assert_quick_filter_bar_visible(true);
-}
-
-function test_control_shift_k_triggers_display() {
- // hide it
- toggle_quick_filter_bar();
- assert_quick_filter_bar_visible(false);
-
- // focus explicitly on the thread pane so we know where the focus is.
- mc.e("threadTree").focus();
-
- // hit control-shift-k
- mc.keypress(null, "k", { accelKey: true, shiftKey: true });
-
- // now we should be visible again!
- assert_quick_filter_bar_visible(true);
-}
-
-function test_constraints_disappear_when_collapsed() {
- // set some constraints
- toggle_boolean_constraints("starred");
- assert_constraints_expressed({ starred: true });
- assert_messages_in_view(setStarred);
-
- // collapse, now we should see them all again!
- toggle_quick_filter_bar();
- assert_messages_in_view([setUnstarred, setStarred]);
-
- // uncollapse, we should still see them all!
- toggle_quick_filter_bar();
- assert_messages_in_view([setUnstarred, setStarred]);
-
- // there better be no constraints left!
- assert_constraints_expressed({});
-}
-
-function teardownTest() {
- clear_constraints();
- // make it visible if it's not
- if (mc.e("quick-filter-bar").collapsed) {
- toggle_quick_filter_bar();
- }
-}
deleted file mode 100755
--- a/mail/test/mozmill/runtest.py
+++ /dev/null
@@ -1,578 +0,0 @@
-#!/usr/bin/env python
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-from base64 import b64decode
-from time import sleep
-import atexit
-import imp
-import jsbridge
-import json
-import mozcrash
-import mozmill
-import mozprofile
-import mozrunner
-import os
-import platform
-import shutil
-import stat
-import subprocess
-import sys
-import tempfile
-
-SCRIPT_DIRECTORY = os.path.abspath(os.path.realpath(os.path.dirname(sys.argv[0])))
-sys.path.append(SCRIPT_DIRECTORY)
-
-PROFILE_DIR = os.path.join(tempfile.gettempdir(), 'mozmillprofile')
-SYMBOLS_PATH = None
-PLUGINS_PATH = None
-# XXX This breaks any semblance of test runner modularity, and only works
-# because we know that we run MozMill only once per process. This needs to be
-# fixed if that ever changes.
-TEST_NAME = None
-
-# The name of the (optional) module that tests can define as a wrapper (e.g. to
-# run before Thunderbird is started)
-WRAPPER_MODULE_NAME = "wrapper"
-
-# The wrapper module (if any) for the test. Just like TEST_NAME, this breaks any
-# semblance of modularity.
-wrapper = None
-
-# Shall we print out a big blob of base64 to allow post-processors to print out
-# a screenshot at the time the failure happened?
-USE_RICH_FAILURES = False
-
-# Save screenshots of failures, so they can be uploaded as a TaskCluster artifact?
-UPLOAD_SCREENSHOTS = False
-
-
-# We need this because rmtree-ing read-only files fails on Windows
-def rmtree_onerror(func, path, exc_info):
- """
- Error handler for ``shutil.rmtree``.
-
- If the error is due to an access error (read only file)
- it attempts to add write permission and then retries.
-
- If the error is for another reason it re-raises the error.
-
- Usage: ``shutil.rmtree(path, onerror=rmtree_onerror)``
- """
- if not os.access(path, os.W_OK):
- # Is the error an access error ?
- os.chmod(path, stat.S_IWUSR)
- func(path)
- else:
- raise
-
-
-class ThunderTestProfile(mozprofile.ThunderbirdProfile):
- preferences = {
- 'calendar.icaljs': False,
- # say yes to debug output via dump
- 'browser.dom.window.dump.enabled': True,
- # say no to slow script warnings
- 'dom.max_chrome_script_run_time': 0,
- 'dom.max_script_run_time': 0,
- # disable extension stuffs
- 'extensions.update.enabled': False,
- 'extensions.update.notifyUser': False,
- # don't warn about third party extensions in profile or elsewhere.
- 'extensions.autoDisableScopes': 10,
- # do not ask about being the default mail client
- 'mail.shell.checkDefaultClient': False,
- # do not tell us about the greatness that is mozilla (about:rights)
- 'mail.rights.override': True,
- # disable non-gloda indexing daemons
- 'mail.winsearch.enable': False,
- 'mail.winsearch.firstRunDone': True,
- 'mail.spotlight.enable': False,
- 'mail.spotlight.firstRunDone': True,
- # disable address books for undisclosed reasons
- 'ldap_2.servers.osx.position': 0,
- 'ldap_2.servers.oe.position': 0,
- # disable the first use junk dialog
- 'mailnews.ui.junk.firstuse': False,
- # set the relative dirs properly
- 'mail.root.none-rel': "[ProfD]Mail",
- 'mail.root.pop3-rel': "[ProfD]Mail",
- # Do not allow check new mail to be set
- 'mail.startup.enabledMailCheckOnce': True,
- # Disable compatibility checking
- 'extensions.checkCompatibility.nightly': False,
- # Stop any pings to AMO on add-on install
- 'extensions.getAddons.cache.enabled': False,
- # In case a developer is working on a laptop without a network
- # connection, don't detect offline mode; hence we'll still startup
- # online which is what mozmill currently requires. It'll also protect us
- # from any random network failures.
- 'offline.autoDetect': False,
- # Don't load what's new or the remote start page - keep everything local
- # under our control.
- 'mailnews.start_page_override.mstone': "ignore",
- 'mailnews.start_page.url': "about:blank",
- # Do not enable gloda
- 'mailnews.database.global.indexer.enabled': False,
- # But do have gloda log if it does anything. (When disabled, queries
- # are still serviced; they just should not result in any matches.)
- 'mailnews.database.global.logging.upstream': True,
- # Do not allow fonts to be upgraded
- 'mail.font.windows.version': 2,
- # No, we don't want to be prompted about Telemetry
- 'toolkit.telemetry.prompted': 999,
- }
-
- menubar_preferences = {
- # Many tests operate items in the main menu, so keep it shown
- # until they are migrated to appmenu.
- 'mail.main_menu.collapse_by_default': False,
- }
-
- # Dummied up local accounts to stop the account wizard
- account_preferences = {
- 'mail.account.account1.server': "server1",
- 'mail.account.account2.identities': "id1,id2",
- 'mail.account.account2.server': "server2",
- 'mail.account.account3.server': "server3",
- 'mail.accountmanager.accounts': "account1,account2,account3",
- 'mail.accountmanager.defaultaccount': "account2",
- 'mail.accountmanager.localfoldersserver': "server1",
- 'mail.identity.id1.fullName': "Tinderbox",
- 'mail.identity.id1.htmlSigFormat': False,
- 'mail.identity.id1.htmlSigText': "Tinderbox is soo 90ies",
- 'mail.identity.id1.smtpServer': "smtp1",
- 'mail.identity.id1.useremail': "tinderbox@foo.invalid",
- 'mail.identity.id1.valid': True,
- 'mail.identity.id2.fullName': "Tinderboxpushlog",
- 'mail.identity.id2.htmlSigFormat': True,
- 'mail.identity.id2.htmlSigText': "Tinderboxpushlog is the new <b>hotness!</b>",
- 'mail.identity.id2.smtpServer': "smtp1",
- 'mail.identity.id2.useremail': "tinderboxpushlog@foo.invalid",
- 'mail.identity.id2.valid': True,
- 'mail.server.server1.directory-rel': "[ProfD]Mail/Local Folders",
- 'mail.server.server1.hostname': "Local Folders",
- 'mail.server.server1.name': "Local Folders",
- 'mail.server.server1.type': "none",
- 'mail.server.server1.userName': "nobody",
- 'mail.server.server2.check_new_mail': False,
- 'mail.server.server2.directory-rel': "[ProfD]Mail/tinderbox",
- 'mail.server.server2.download_on_biff': True,
- 'mail.server.server2.hostname': "tinderbox123",
- 'mail.server.server2.login_at_startup': False,
- 'mail.server.server2.name': "tinderbox@foo.invalid",
- 'mail.server.server2.type': "pop3",
- 'mail.server.server2.userName': "tinderbox",
- 'mail.server.server2.whiteListAbURI': "",
- 'mail.server.server3.hostname': "prpl-irc",
- 'mail.server.server3.imAccount': "account1",
- 'mail.server.server3.type': "im",
- 'mail.server.server3.userName': "mozmilltest@irc.mozilla.invalid",
- 'mail.smtp.defaultserver': "smtp1",
- 'mail.smtpserver.smtp1.hostname': "tinderbox123",
- 'mail.smtpserver.smtp1.username': "tinderbox",
- 'mail.smtpservers': "smtp1",
- 'messenger.account.account1.autoLogin': False,
- 'messenger.account.account1.firstConnectionState': 1,
- 'messenger.account.account1.name': "mozmilltest@irc.mozilla.invalid",
- 'messenger.account.account1.prpl': "prpl-irc",
- 'messenger.accounts': "account1",
- }
-
- def __init__(self, *args, **kwargs):
- kwargs['profile'] = self.get_profile_dir()
- super(ThunderTestProfile, self).__init__(*args, **kwargs)
- self.set_preferences(self.preferences)
-
- if (wrapper is not None and
- hasattr(wrapper, "DEFAULT_MENUBAR") and
- wrapper.DEFAULT_MENUBAR):
- pass
- else:
- self.set_preferences(self.menubar_preferences)
-
- if (wrapper is not None and
- hasattr(wrapper, "NO_ACCOUNTS") and
- wrapper.NO_ACCOUNTS):
- pass
- else:
- self.set_preferences(self.account_preferences)
-
- def get_profile_dir(self):
- '''
- We always put our profile in the same location. We only clear it out
- when we are creating a new profile so that we can go in after the run
- and examine things for debugging or general interest.
- '''
- # create a clean directory
- if os.path.exists(PROFILE_DIR):
- shutil.rmtree(PROFILE_DIR, onerror=rmtree_onerror)
- os.makedirs(PROFILE_DIR)
- print 'Using profile dir:', PROFILE_DIR
- if not os.path.exists(PROFILE_DIR):
- raise Exception('somehow failed to create profile dir!')
-
- if PLUGINS_PATH:
- if not os.path.exists(PLUGINS_PATH):
- raise Exception('Plugins path "%s" does not exist.' % PLUGINS_PATH)
-
- dest = os.path.join(PROFILE_DIR, "plugins")
- shutil.copytree(PLUGINS_PATH, dest)
-
- if wrapper is not None:
- if hasattr(wrapper, "on_profile_created"):
- # It's a little dangerous to allow on_profile_created access to the
- # profile object, because it isn't fully initialized yet
- wrapper.on_profile_created(PROFILE_DIR)
-
- if hasattr(wrapper, "PREFS"):
- with open(os.path.join(PROFILE_DIR, "user.js"), "w") as user_js:
- for key, value in wrapper.PREFS.iteritems():
- if value is True:
- value = "true"
- elif value is False:
- value = "false"
- elif not isinstance(value, int):
- value = "\"%s\"" % value
- user_js.write("pref(\"%s\", %s);\n" % (key, value))
-
- with open(os.path.join(PROFILE_DIR, "user.js")) as user_js:
- print user_js.read()
-
- return PROFILE_DIR
-
- def cleanup(self):
- '''
- Do not cleanup at all. The next iteration will cleanup for us, but
- until that time it's useful for debugging failures to leave everything
- around.
- '''
- pass
-
-
-def ThunderTestRunner(*args, **kwargs):
- kwargs['env'] = env = dict(os.environ)
- # note, we do NOT want to set NO_EM_RESTART or jsbridge wouldn't work
- # avoid dialogs on windows
- if 'NO_EM_RESTART' in env:
- del env['NO_EM_RESTART']
- if 'XPCOM_DEBUG_BREAK' not in env:
- env['XPCOM_DEBUG_BREAK'] = 'stack'
- # do not reuse an existing instance
- env['MOZ_NO_REMOTE'] = '1'
-
- return mozrunner.ThunderbirdRunner(*args, **kwargs)
-
-
-class ThunderTestMozmill(mozmill.MozMill):
- VNC_SERVER_PATH = '/usr/bin/vncserver'
- VNC_PASSWD_PATH = '~/.vnc/passwd'
-
- def __init__(self, *args, **kwargs):
- # Only use the VNC server if the capability is available and a password
- # is already defined so this can run without prompting the user.
- self.use_vnc_server = (
- platform.system() == 'Linux' and
- os.path.isfile(self.VNC_SERVER_PATH) and
- os.path.isfile(os.path.expanduser(self.VNC_PASSWD_PATH)) and
- os.environ.get('MOZMILL_NO_VNC') != '1')
-
- global USE_RICH_FAILURES
- USE_RICH_FAILURES = (os.environ.get('MOZMILL_RICH_FAILURES') == '1')
-
- super(ThunderTestMozmill, self).__init__(*args, **kwargs)
-
- def start(self, profile=None, runner=None):
- if not profile:
- profile = self.profile_class(addons=[jsbridge.extension_path, extension_path])
- self.profile = profile
-
- if not runner:
- runner = self.runner_class(profile=self.profile,
- cmdargs=["-jsbridge", str(self.jsbridge_port)])
- self.runner = runner
-
- if self.use_vnc_server:
- try:
- subprocess.check_call([self.VNC_SERVER_PATH, ':99'])
- except subprocess.CalledProcessError:
- # Okay, so that display probably already exists. We can either
- # use it as-is or kill it. I'm deciding we want to kill it
- # since there might be other processes alive in there that
- # want to make trouble for us.
- subprocess.check_call([self.VNC_SERVER_PATH, '-kill', ':99'])
- # Now let's try again. if this didn't work, let's just let
- # the exception kill us.
- subprocess.check_call([self.VNC_SERVER_PATH, ':99'])
- self.vnc_alive = True
- self.runner.env['DISPLAY'] = ':99'
-
- if wrapper is not None and hasattr(wrapper, "on_before_start"):
- wrapper.on_before_start(self.runner.profile)
-
- return super(ThunderTestMozmill, self).start(profile, runner)
-
- def stop_runner(self, *args, **kwargs):
- '''
- Wrap the call to wait in logic that kills the VNC server when we are
- done waiting. During normal operation, wait is the last thing. In
- the keyboard interrupt case wait will die due to the interrupt and
- stop/kill will be killed. Since we are wrapping wait, we don't need
- to specialize for stop/kill though.
- '''
- try:
- return super(ThunderTestMozmill, self).stop_runner(*args, **kwargs)
- finally:
- try:
- if self.use_vnc_server and self.vnc_alive:
- subprocess.check_call([self.VNC_SERVER_PATH,
- '-kill', ':99'])
- except Exception, ex:
- print '!!! Exception during killing VNC server:', ex
-
-
-def monkeypatched_15_run_tests(self, tests, sleeptime=0):
- frame = mozmill.jsbridge.JSObject(self.bridge,
- "ChromeUtils.import('resource://testing-common/mozmill/frame.jsm')")
- sleep(sleeptime)
-
- # transfer persisted data
- frame.persisted = self.persisted
-
- if len(tests) == 1 and not os.path.isdir(tests[0]):
- # tests[0] isn't necessarily an abspath'd path, so do that now
- test = os.path.abspath(tests[0])
- frame.runTestFile(test)
- else:
- # run the test files
- for test_dir in self.test_dirs:
- frame.runTestDirectory(test_dir)
-
- # Give a second for any callbacks to finish.
- sleep(1)
-
-if hasattr(mozmill.MozMill, 'find_tests'):
- # Monkey-patch run_tests
- mozmill.MozMill.old_run_tests = mozmill.MozMill.run_tests
- mozmill.MozMill.run_tests = monkeypatched_15_run_tests
-
-
-class ThunderTestCLI(mozmill.CLI):
- mozmill_class = ThunderTestMozmill
-
- def add_options(self, parser):
- mozmill.CLI.add_options(self, parser)
- parser.add_option('--symbols-path', default=None, dest="symbols",
- help="The path to the symbol files from build_symbols")
- parser.add_option('--plugins-path', default=None, dest="plugins",
- help="The path to the plugins directory for the created profile")
- parser.add_option('--testing-modules-dir', default=None,
- dest="testingmodules",
- help="The path to the testing modules directory")
-
- def __init__(self, *args, **kwargs):
- global SYMBOLS_PATH, PLUGINS_PATH, TEST_NAME
-
- # note: we previously hardcoded a JS bridge timeout of 300 seconds,
- # but the default is now 90 seconds...
- mozmill.CLI.__init__(self, *args, **kwargs)
-
- # Mozrunner expects the filename on OS X to point to the executable, but
- # we only have the directory passed in. Remedy this.
- if (sys.platform == 'darwin' and
- self.options.binary.find('Contents/MacOS/') == -1):
- self.options.binary = os.path.join(self.options.binary,
- 'Contents/MacOS/thunderbird-bin')
-
- # Add these manually after the fact. No way to override the defaults
- # from mozrunner that I can see.
- self.runner_class = ThunderTestRunner
- self.profile_class = ThunderTestProfile
-
- SYMBOLS_PATH = self.options.symbols
- PLUGINS_PATH = self.options.plugins
- os.environ['TESTING_MODULES_DIR'] = self.options.testingmodules
- if isinstance(self.options.test, basestring):
- test_paths = [self.options.test]
- else:
- test_paths = self.options.test
- TEST_NAME = ', '.join([os.path.basename(t) for t in test_paths])
-
- test_dirs = self.test_dirs = []
- for test_file in test_paths:
- test_file = os.path.abspath(test_file)
- if not os.path.isdir(test_file):
- test_file = os.path.dirname(test_file)
- if test_file not in test_dirs:
- test_dirs.append(test_file)
-
- # if we are monkeypatching, give it the test directories.
- if hasattr(self.mozmill, 'find_tests'):
- self.mozmill.test_dirs = test_dirs
-
- self._load_wrapper()
-
- def _load_wrapper(self):
- global wrapper
- """
- Load the wrapper module if it is present in the test directory.
- """
- if len(self.test_dirs) > 1:
- raise Exception("Wrapper semantics require only a single test dir")
- testdir = self.test_dirs[0]
-
- try:
- (fd, path, desc) = imp.find_module(WRAPPER_MODULE_NAME, [testdir])
- except ImportError:
- # No wrapper module, which is fine.
- pass
- else:
- try:
- wrapper = imp.load_module(WRAPPER_MODULE_NAME, fd, path, desc)
- finally:
- if fd is not None:
- fd.close()
-
-
-TEST_RESULTS = []
-
-
-# Versions of MozMill prior to 1.5 did not output test-pass /
-# TEST-UNEXPECTED-FAIL. Since 1.5 happened this gets output, so we only want
-# a summary at the end to make it easy for developers.
-def logEndTest(obj):
- # If we've got a string here, we know we're later than 1.5, and we can just
- # display a summary at the end as 1.5 will do TEST-UNEXPECTED-FAIL for us.
- if isinstance(obj, str):
- obj = json.loads(obj)
- obj['summary'] = True
- TEST_RESULTS.append(obj)
-mozmill.LoggerListener.cases['mozmill.endTest'] = logEndTest
-
-# We now send extended meta-data about failures. We do not want the entire
-# message dumped with this extra data, so clobber the default mozmill.fail
-# with one that wraps it and only tells it the exception message rather than
-# the whole JSON blob.
-ORIGINAL_FAILURE_LOGGER = mozmill.LoggerListener.cases['mozmill.fail']
-
-
-def logFailure(obj):
- if isinstance(obj, basestring):
- obj = json.loads(obj)
- if 'exception' in obj:
- objex = obj['exception']
- if 'message' in objex:
- report_as = objex['message']
- else:
- report_as = 'Empty object thrown as an exception somehow'
- else:
- report_as = 'No exception provided'
- ORIGINAL_FAILURE_LOGGER(report_as)
-mozmill.LoggerListener.cases['mozmill.fail'] = logFailure
-
-
-def prettifyFilename(path, tail_segs_desired=1):
- parts = path.split('/')
- return '/'.join(parts[-tail_segs_desired:])
-
-
-def prettyPrintException(e):
- print ' EXCEPTION:', e.get('message', 'no message!').encode('utf-8')
- print ' at:', prettifyFilename(e.get('fileName', 'nonesuch')), 'line', e.get('lineNumber', 0)
- if 'stack' in e:
- for line in e['stack'].splitlines():
- if not line:
- continue
- if line[0] == "(":
- funcname = None
- elif line[0] == "@":
- # this is probably the root, don't care
- continue
- else:
- funcname = line[:line.find('@')]
- pathAndLine = line[line.rfind('@') + 1:]
- rcolon = pathAndLine.rfind(':')
- if rcolon != -1:
- path = pathAndLine[:rcolon]
- line = pathAndLine[rcolon + 1:]
- else:
- path = pathAndLine
- line = 0
- if funcname:
- print ' ', funcname, prettifyFilename(path), line
- else:
- print ' ', prettifyFilename(path), line
-
-
-# Tests that are useless and shouldn't be printed if successful
-TEST_BLACKLIST = ["setupModule", "setupTest", "teardownTest", "teardownModule"]
-
-
-@atexit.register
-def prettyPrintResults():
- for result in TEST_RESULTS:
- testOrSummary = 'TEST'
- if 'summary' in result:
- testOrSummary = 'SUMMARY'
- if len(result['fails']) == 0:
- if result.get('skipped', False):
- kind = 'SKIP'
- else:
- kind = 'PASS'
- if result['name'] not in TEST_BLACKLIST:
- print '%s-%s | %s' % (testOrSummary, kind, result['name'])
- else:
- print '%s-UNEXPECTED-FAIL | %s | %s' % \
- (testOrSummary, prettifyFilename(result['filename']), result['name'])
- for failure in result['fails']:
- if 'exception' in failure:
- prettyPrintException(failure['exception'])
-
-
-@atexit.register
-def dumpRichResults():
- if USE_RICH_FAILURES:
- print '##### MOZMILL-RICH-FAILURES-BEGIN #####'
- for result in TEST_RESULTS:
- if len(result['fails']) > 0:
- for failure in result['fails']:
- failure['fileName'] = prettifyFilename(result['filename'], 2)
- failure['testName'] = result['name']
- print json.dumps(failure)
- print '##### MOZMILL-RICH-FAILURES-END #####'
-
-
-@atexit.register
-def uploadScreenshots():
- if not UPLOAD_SCREENSHOTS:
- return
-
- parent_dir = os.environ.get('MOZ_UPLOAD_DIR', None)
- if not parent_dir:
- return
-
- for result in TEST_RESULTS:
- for failure in result['fails']:
- for win in failure['failureContext']['windows']['windows']:
- prefix = result['name'].replace(':', '_')
- fp, path = tempfile.mkstemp(prefix=prefix + '-', suffix='.png', dir=parent_dir)
- with os.fdopen(fp, 'wb') as shot:
- shot.write(b64decode(win['screenshotDataUrl'][len('data:image/png;base64,'):]))
- print 'Wrote screenshot to', path
-
-
-def checkCrashesAtExit():
- if mozcrash.check_for_crashes(dump_directory=os.path.join(PROFILE_DIR, 'minidumps'),
- symbols_path=SYMBOLS_PATH,
- test_name=TEST_NAME):
- print >> sys.stderr, 'TinderboxPrint: ' + TEST_NAME + '<br/><em class="testfail">CRASH</em>'
- sys.exit(1)
-
-if __name__ == '__main__':
- # Too bad atexit doesn't return a non-zero exit code when it encounters an
- # exception in a handler.
- try:
- ThunderTestCLI().run()
- finally:
- checkCrashesAtExit()
deleted file mode 100755
--- a/mail/test/mozmill/runtestlist.py
+++ /dev/null
@@ -1,167 +0,0 @@
-#!/usr/bin/env python
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-import glob
-import optparse
-import sys
-import os
-import subprocess
-import logging
-
-SCRIPT_DIRECTORY = os.path.abspath(os.path.realpath(os.path.dirname(sys.argv[0])))
-
-
-class RunTestListOptions(optparse.OptionParser):
- """Parsed run test list command line options."""
- def __init__(self, **kwargs):
- optparse.OptionParser.__init__(self, **kwargs)
- defaults = {}
-
- self.add_option("--binary",
- action="store", type="string", dest="binary",
- help="Binary to be run")
- defaults["binary"] = ""
-
- self.add_option("--list",
- action="store", type="string", dest="list",
- help="List of tests to be run")
- defaults["list"] = ""
-
- self.add_option("--dir",
- action="store", type="string", dest="dir",
- help="Directory of the tests, leave blank for current directory")
- defaults["dir"] = ""
-
- self.add_option("--symbols-path",
- action="store", type="string", dest="symbols",
- help="The path to the symbol files from build_symbols")
- defaults["symbols"] = ""
-
- self.add_option("--total-chunks",
- action="store", type="int", dest="total_chunks",
- help="how many chunks to split the tests up into")
- defaults["total_chunks"] = 1
- self.add_option("--this-chunk",
- action="store", type="int", dest="this_chunk",
- help="which chunk to run between 1 and --total-chunks")
- defaults["this_chunk"] = 1
-
- self.add_option("--plugins-path",
- action="store", type="string", dest="plugins",
- help="The path to the plugins folder for the test profiles")
-
- self.add_option("--testing-modules-dir",
- action="store", type="string", dest="testingmodules",
- help="The path to the testing modules directory")
- defaults["testingmodules"] = ""
-
- # We ignore this argument when passed from automation.
- self.add_option("--setpref",
- action="store", type="string")
-
- self.set_defaults(**defaults)
-
- usage = """\
-Usage instructions for runtestlist.py
-"""
- self.set_usage(usage)
-
-log = logging.getLogger()
-handler = logging.StreamHandler(sys.stdout)
-log.setLevel(logging.INFO)
-log.addHandler(handler)
-
-parser = RunTestListOptions()
-options, args = parser.parse_args()
-
-if options.binary == "" or options.list == "":
- parser.print_help()
- sys.exit(1)
-
-totalTestErrors = 0
-totalTestPasses = 0
-totalDirectories = 0
-
-tests = [t.strip() for t in open(options.list, "rt").readlines()]
-
-if options.total_chunks > 1:
- test_counts = {}
- total_test_count = 0
- for t in tests:
- if os.path.isdir(os.path.join(SCRIPT_DIRECTORY, t)):
- test_counts[t] = len(glob.glob(os.path.join(SCRIPT_DIRECTORY, t, "test*.js")))
- else:
- test_counts[t] = 1
- total_test_count += test_counts[t]
-
- tests_per_chunk = float(total_test_count) / options.total_chunks
- start = int(round((options.this_chunk - 1) * tests_per_chunk))
- end = int(round(options.this_chunk * tests_per_chunk))
-
- chunk_tests = []
- cumulative_test_count = 0
- for t in tests:
- if cumulative_test_count >= end:
- break
- if cumulative_test_count >= start:
- chunk_tests.append(t)
- cumulative_test_count += test_counts[t]
- tests = chunk_tests
-
-for directory in tests:
- log.info("INFO | (runtestlist.py) | Running directory: %s",
- directory.rstrip())
- if options.dir != "":
- testDirectory = os.path.join(options.dir, directory.rstrip())
- else:
- testDirectory = directory.rstrip()
- args = [sys.executable, "runtest.py", "-t", testDirectory,
- "--binary", os.path.abspath(options.binary), "--symbols-path", options.symbols]
-
- if options.plugins:
- args.append("--plugins-path")
- args.append(options.plugins)
-
- if options.testingmodules:
- args.append("--testing-modules-dir")
- args.append(os.path.abspath(options.testingmodules))
-
- print args
- outputPipe = subprocess.PIPE
-
- proc = subprocess.Popen(args, cwd=SCRIPT_DIRECTORY, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-
- testErrors = 0
- testPasses = 0
-
- line = proc.stdout.readline()
- while line != "":
- log.info(line.rstrip())
- if line.find("TEST-UNEXPECTED-") != -1:
- testErrors += 1
- if line.find("TEST-PASS") != -1:
- testPasses += 1
- line = proc.stdout.readline()
-
- result = proc.wait()
-
- if result != 0:
- log.info("TEST-UNEXPECTED-FAIL | (runtestlist.py) | Exited with code %d during directory run", result)
- totalTestErrors += 1
- else:
- totalTestPasses += 1
-
- log.info("INFO | (runtestlist.py) | %s: %d passed, %d failed",
- directory.rstrip(), testPasses, testErrors)
- totalTestErrors += testErrors
- totalTestPasses += testPasses
- totalDirectories += 1
-
-
-log.info("INFO | (runtestlist.py) | Directories Run: %d, Passed: %d, Failed: %d",
- totalDirectories, totalTestPasses, totalTestErrors)
-
-if totalTestErrors:
- sys.exit(1)
deleted file mode 100644
--- a/mail/test/mozmill/search-window/test-multiple-search-windows.js
+++ /dev/null
@@ -1,73 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test that we open multiple search windows when shortcuts are invoked multiple
- * times.
- */
-
-"use strict";
-
-var { be_in_folder, create_folder, mc } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var {
- assert_search_window_folder_displayed,
- close_search_window,
- open_search_window,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/SearchWindowHelpers.jsm"
-);
-
-var folderA, folderB;
-function setupModule(module) {
- folderA = create_folder("MultipleSearchWindowsA");
- folderB = create_folder("MultipleSearchWindowsB");
-}
-
-/**
- * Test bringing up multiple search windows for multiple folders.
- */
-function test_show_multiple_search_windows_for_multiple_folders() {
- be_in_folder(folderA);
-
- let swcA = open_search_window();
- // Check whether the window's displaying the right folder
- assert_search_window_folder_displayed(swcA, folderA);
-
- mc.window.focus();
- be_in_folder(folderB);
- // This should time out if a second search window isn't opened
- let swcB = open_search_window();
-
- // Now check whether both windows are displaying the right folders
- assert_search_window_folder_displayed(swcA, folderA);
- assert_search_window_folder_displayed(swcB, folderB);
-
- // Clean up, close both windows
- close_search_window(swcA);
- close_search_window(swcB);
-}
-
-/**
- * Test bringing up multiple search windows for the same folder.
- */
-function test_show_multiple_search_windows_for_the_same_folder() {
- be_in_folder(folderA);
- let swc1 = open_search_window();
- // Check whether the window's displaying the right folder
- assert_search_window_folder_displayed(swc1, folderA);
-
- mc.window.focus();
- // This should time out if a second search window isn't opened
- let swc2 = open_search_window();
-
- // Now check whether both windows are displaying the right folders
- assert_search_window_folder_displayed(swc1, folderA);
- assert_search_window_folder_displayed(swc2, folderA);
-
- // Clean up, close both windows
- close_search_window(swc1);
- close_search_window(swc2);
-}
deleted file mode 100644
--- a/mail/test/mozmill/search-window/test-right-click-to-open-search-window.js
+++ /dev/null
@@ -1,71 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-var {
- assert_folders_selected_and_displayed,
- assert_no_folders_selected,
- create_folder,
- enter_folder,
- select_click_folder,
- select_no_folders,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var {
- assert_search_window_folder_displayed,
- close_search_window,
- open_search_window,
- open_search_window_from_context_menu,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/SearchWindowHelpers.jsm"
-);
-
-var folderA, folderB;
-function setupModule(module) {
- folderA = create_folder("RightClickToOpenSearchWindowA");
- folderB = create_folder("RightClickToOpenSearchWindowB");
-}
-
-/**
- * Test opening a search window while nothing is selected.
- */
-function test_open_search_window_with_nothing_selected() {
- // Make sure the folders we need are visible
- enter_folder(folderB);
- select_no_folders();
- assert_no_folders_selected();
-
- let swc = open_search_window_from_context_menu(folderA);
- assert_search_window_folder_displayed(swc, folderA);
-
- close_search_window(swc);
-}
-
-/**
- * Test opening a search window while the same folder is selected.
- */
-function test_open_search_window_with_existing_single_selection() {
- select_click_folder(folderA);
- assert_folders_selected_and_displayed(folderA);
-
- let swc = open_search_window_from_context_menu(folderA);
- assert_search_window_folder_displayed(swc, folderA);
-
- close_search_window(swc);
-}
-
-/**
- * Test opening a search window while a different folder is selected.
- */
-function test_open_search_window_with_one_thing_selected() {
- select_click_folder(folderA);
- assert_folders_selected_and_displayed(folderA);
-
- let swc = open_search_window_from_context_menu(folderB);
- assert_search_window_folder_displayed(swc, folderB);
-
- close_search_window(swc);
-}
deleted file mode 100644
--- a/mail/test/mozmill/search-window/test-search-window.js
+++ /dev/null
@@ -1,338 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Tests:
- * - https://bugzilla.mozilla.org/show_bug.cgi?id=474701#c96 first para
- */
-
-"use strict";
-
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-
-var {
- assert_messages_in_view,
- assert_number_of_tabs_open,
- assert_selected_and_displayed,
- assert_tab_mode_name,
- assert_tab_titled_from,
- be_in_folder,
- close_message_window,
- close_tab,
- create_folder,
- make_new_sets_in_folder,
- mc,
- open_selected_message,
- open_selected_messages,
- plan_for_message_display,
- reset_open_message_behavior,
- select_click_row,
- select_shift_click_row,
- set_open_message_behavior,
- switch_tab,
- wait_for_all_messages_to_load,
- wait_for_message_display_completion,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var {
- assert_search_window_folder_displayed,
- open_search_window,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/SearchWindowHelpers.jsm"
-);
-var {
- plan_for_modal_dialog,
- plan_for_new_window,
- plan_for_window_close,
- wait_for_modal_dialog,
- wait_for_new_window,
- wait_for_window_close,
-} = ChromeUtils.import("resource://testing-common/mozmill/WindowHelpers.jsm");
-
-var folder, setFoo, setBar, setFooBar;
-
-// Number of messages to open for multi-message tests
-var NUM_MESSAGES_TO_OPEN = 5;
-
-/**
- * Create some messages that our constraint below will satisfy
- */
-function test_create_messages() {
- folder = create_folder("SearchWindowA");
- [setFoo, setBar, setFooBar] = make_new_sets_in_folder(folder, [
- { subject: "foo" },
- { subject: "bar" },
- { subject: "foo bar" },
- ]);
-}
-
-/**
- * The search window controller.
- */
-var swc = null;
-
-/**
- * Bring up the search window.
- */
-function test_show_search_window() {
- // put us in the folder we care about so it defaults to that
- be_in_folder(folder);
-
- swc = open_search_window();
- assert_search_window_folder_displayed(swc, folder);
-}
-
-/**
- * Set up the search.
- */
-function test_enter_some_stuff() {
- // - turn off search subfolders
- // (we're not testing the UI, direct access is fine)
- swc.e("checkSearchSubFolders").removeAttribute("checked");
-
- // - put "foo" in the subject contains box
- // Each filter criterion is a listitem in the listbox with id=searchTermList.
- // Each filter criterion has id "searchRowN", and the textbox has id
- // "searchValN" exposing the value on attribute "value".
- // XXX I am having real difficulty getting the click/type pair to actually
- // get the text in there reliably. I am just going to poke things directly
- // into the text widget. (We used to use .aid instead of .a with swc.click
- // and swc.type.)
- let searchVal0 = swc.window.document.getElementById("searchVal0");
- let index = 0;
-
- if (searchVal0.hasAttribute("selectedIndex")) {
- index = parseInt(searchVal0.getAttribute("selectedIndex"));
- }
-
- searchVal0 = searchVal0.children[index];
- searchVal0.value = "foo";
-
- // - add another subject box
- let plusButton = swc.eid("searchRow0", { tagName: "button", label: "+" });
- swc.click(plusButton);
-
- // - put "bar" in it
- let searchVal1 = swc.window.document.getElementById("searchVal1");
- index = 0;
-
- if (searchVal1.hasAttribute("selectedIndex")) {
- index = parseInt(searchVal1.getAttribute("selectedIndex"));
- }
-
- searchVal1 = searchVal1.children[index];
- searchVal1.value = "bar";
-}
-
-/**
- * Trigger the search, make sure the right results show up.
- */
-function test_go_search() {
- // - Trigger the search
- // The "Search" button has id "search-button"
- swc.click(swc.eid("search-button"));
- wait_for_all_messages_to_load(swc);
-
- // - Verify we got the right messages
- assert_messages_in_view(setFooBar, swc);
-
- // - Click the "Save as Search Folder" button, id "saveAsVFButton"
- // This will create a virtual folder properties dialog...
- // (label: "New Saved Search Folder", source: virtualFolderProperties.xhtml
- // no windowtype, id: "virtualFolderPropertiesDialog")
- plan_for_modal_dialog(
- "mailnews:virtualFolderProperties",
- subtest_save_search
- );
- swc.click(swc.eid("saveAsVFButton"));
- wait_for_modal_dialog("mailnews:virtualFolderProperties");
-}
-
-/**
- * Test opening a single search result in a new tab.
- */
-function test_open_single_search_result_in_tab() {
- swc.window.focus();
- set_open_message_behavior("NEW_TAB");
- let folderTab = mc.tabmail.currentTabInfo;
- let preCount = mc.tabmail.tabContainer.allTabs.length;
-
- // Select one message
- swc.e("threadTree").focus();
- let msgHdr = select_click_row(1, swc);
- // Open the selected message
- open_selected_message(swc);
- // This is going to trigger a message display in the main 3pane window
- wait_for_message_display_completion(mc);
- // Check that the tab count has increased by 1
- assert_number_of_tabs_open(preCount + 1);
- // Check that the currently displayed tab is a message tab (i.e. our newly
- // opened tab is in the foreground)
- assert_tab_mode_name(null, "message");
- // Check that the message header displayed is the right one
- assert_selected_and_displayed(msgHdr);
- // Clean up, close the tab
- close_tab(mc.tabmail.currentTabInfo);
- switch_tab(folderTab);
- reset_open_message_behavior();
-}
-
-/**
- * Test opening multiple search results in new tabs.
- */
-function test_open_multiple_search_results_in_new_tabs() {
- swc.window.focus();
- set_open_message_behavior("NEW_TAB");
- let folderTab = mc.tabmail.currentTabInfo;
- let preCount = mc.tabmail.tabContainer.allTabs.length;
-
- // Select a bunch of messages
- swc.e("threadTree").focus();
- select_click_row(1, swc);
- let selectedMessages = select_shift_click_row(NUM_MESSAGES_TO_OPEN, swc);
- // Open them
- open_selected_messages(swc);
- // This is going to trigger a message display in the main 3pane window
- wait_for_message_display_completion(mc, true);
- // Check that the tab count has increased by the correct number
- assert_number_of_tabs_open(preCount + NUM_MESSAGES_TO_OPEN);
- // Check that the currently displayed tab is a message tab (i.e. one of our
- // newly opened tabs is in the foreground)
- assert_tab_mode_name(null, "message");
-
- // Now check whether each of the NUM_MESSAGES_TO_OPEN tabs has the correct
- // title
- for (let i = 0; i < NUM_MESSAGES_TO_OPEN; i++) {
- assert_tab_titled_from(
- mc.tabmail.tabInfo[preCount + i],
- selectedMessages[i]
- );
- }
-
- // Check whether each tab has the correct message, then close it to load the
- // previous tab.
- for (let i = 0; i < NUM_MESSAGES_TO_OPEN; i++) {
- assert_selected_and_displayed(selectedMessages.pop());
- close_tab(mc.tabmail.currentTabInfo);
- }
- switch_tab(folderTab);
- reset_open_message_behavior();
-}
-
-/**
- * Test opening a search result in a new window.
- */
-function test_open_search_result_in_new_window() {
- swc.window.focus();
- set_open_message_behavior("NEW_WINDOW");
-
- // Select a message
- swc.e("threadTree").focus();
- let msgHdr = select_click_row(1, swc);
-
- plan_for_new_window("mail:messageWindow");
- // Open it
- open_selected_message(swc);
- let msgc = wait_for_new_window("mail:messageWindow");
- wait_for_message_display_completion(msgc, true);
-
- assert_selected_and_displayed(msgc, msgHdr);
- // Clean up, close the window
- close_message_window(msgc);
- reset_open_message_behavior();
-}
-
-/**
- * Test reusing an existing window to open another search result.
- */
-function test_open_search_result_in_existing_window() {
- swc.window.focus();
- set_open_message_behavior("EXISTING_WINDOW");
-
- // Open up a window
- swc.e("threadTree").focus();
- select_click_row(1, swc);
- plan_for_new_window("mail:messageWindow");
- open_selected_message(swc);
- let msgc = wait_for_new_window("mail:messageWindow");
- wait_for_message_display_completion(msgc, true);
-
- // Select another message and open it
- let msgHdr = select_click_row(2, swc);
- plan_for_message_display(msgc);
- open_selected_message(swc);
- wait_for_message_display_completion(msgc, true);
-
- // Check if our old window displays the message
- assert_selected_and_displayed(msgc, msgHdr);
- // Clean up, close the window
- close_message_window(msgc);
- reset_open_message_behavior();
-}
-
-/**
- * Save the search, making sure the constraints propagated.
- */
-function subtest_save_search(savc) {
- // - make sure our constraint propagated
- // The query constraints are displayed using the same widgets (and code) that
- // we used to enter them, so it's very similar to check.
- let searchVal0 = swc.window.document.getElementById("searchVal0");
- let index = 0;
-
- if (searchVal0.hasAttribute("selectedIndex")) {
- index = parseInt(searchVal0.getAttribute("selectedIndex"));
- }
-
- searchVal0 = new elib.Elem(searchVal0.children[index]);
-
- savc.assertNode(searchVal0);
- savc.assertValue(searchVal0, "foo");
-
- let searchVal1 = swc.window.document.getElementById("searchVal1");
- index = 0;
-
- if (searchVal1.hasAttribute("selectedIndex")) {
- index = parseInt(searchVal1.getAttribute("selectedIndex"));
- }
-
- searchVal1 = new elib.Elem(searchVal1.children[index]);
-
- savc.assertNode(searchVal1);
- savc.assertValue(searchVal1, "bar");
-
- // - name the search
- savc.type(savc.eid("name"), "SearchSaved");
-
- // - save it!
- // this will close the dialog, which wait_for_modal_dialog is making sure
- // happens.
- savc.window.document.documentElement.querySelector("dialog").acceptDialog();
-}
-
-function test_close_search_window() {
- swc.window.focus();
- // now close the search window
- plan_for_window_close(swc);
- swc.keypress(null, "VK_ESCAPE", {});
- wait_for_window_close(swc);
- swc = null;
-}
-
-/**
- * Make sure the folder showed up with the right name, and that displaying it
- * has the right contents.
- */
-function test_verify_saved_search() {
- let savedFolder = folder.getChildNamed("SearchSaved");
- if (savedFolder == null) {
- throw new Error("Saved folder did not show up.");
- }
-
- be_in_folder(savedFolder);
- assert_messages_in_view(setFooBar);
-}
deleted file mode 100644
--- a/mail/test/mozmill/session-store/test-session-store.js
+++ /dev/null
@@ -1,627 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Session Storage Tests. Session Restoration Tests are currently implemented in
- * folder-display/test-message-pane-visibility.js.
- */
-
-"use strict";
-
-var controller = ChromeUtils.import(
- "chrome://mozmill/content/modules/controller.jsm"
-);
-var EventUtils = ChromeUtils.import(
- "chrome://mozmill/content/stdlib/EventUtils.jsm"
-);
-var utils = ChromeUtils.import("chrome://mozmill/content/modules/utils.jsm");
-
-var {
- assert_equals,
- assert_false,
- assert_message_pane_hidden,
- assert_message_pane_visible,
- assert_not_equals,
- assert_pane_layout,
- assert_true,
- be_in_folder,
- create_folder,
- kClassicMailLayout,
- kVerticalMailLayout,
- make_new_sets_in_folder,
- mc,
- set_mc,
- set_pane_layout,
- toggle_message_pane,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var {
- close_window,
- plan_for_new_window,
- plan_for_window_close,
- wait_for_new_window,
- wait_for_window_close,
-} = ChromeUtils.import("resource://testing-common/mozmill/WindowHelpers.jsm");
-
-var { IOUtils } = ChromeUtils.import("resource:///modules/IOUtils.js");
-var { FileUtils } = ChromeUtils.import("resource://gre/modules/FileUtils.jsm");
-var { SessionStoreManager } = ChromeUtils.import(
- "resource:///modules/SessionStoreManager.jsm"
-);
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var folderA, folderB;
-
-// Default JSONFile save delay with saveSoon().
-var kSaveDelayMs = 1500;
-
-// With async file writes, use a delay larger than the session autosave timer.
-var asyncFileWriteDelayMS = 3000;
-
-/* ........ Helper Functions ................*/
-
-/**
- * Reads the contents of the session file into a JSON object.
- */
-function readFile() {
- try {
- let data = IOUtils.loadFileToString(SessionStoreManager.sessionFile);
- if (data) {
- return JSON.parse(data);
- }
- } catch (ex) {
- // fall through and return null if the session file cannot be read
- // or is bad
- }
-
- return null;
-}
-
-function waitForFileRefresh() {
- controller.sleep(kSaveDelayMs);
- utils.waitFor(
- () => SessionStoreManager.sessionFile.exists(),
- "session file should exist"
- );
- controller.sleep(asyncFileWriteDelayMS);
-}
-
-function open3PaneWindow() {
- plan_for_new_window("mail:3pane");
- Services.ww.openWindow(
- null,
- "chrome://messenger/content/messenger.xhtml",
- "",
- "all,chrome,dialog=no,status,toolbar",
- null
- );
- return wait_for_new_window("mail:3pane");
-}
-
-function openAddressBook() {
- plan_for_new_window("mail:addressbook");
- Services.ww.openWindow(
- null,
- "chrome://messenger/content/addressbook/addressbook.xhtml",
- "",
- "all,chrome,dialog=no,status,toolbar",
- null
- );
- return wait_for_new_window("mail:addressbook");
-}
-
-/* :::::::: The Tests ::::::::::::::: */
-
-function setupModule(module) {
- folderA = create_folder("SessionStoreA");
- make_new_sets_in_folder(folderA, [{ count: 3 }]);
-
- folderB = create_folder("SessionStoreB");
- make_new_sets_in_folder(folderB, [{ count: 3 }]);
-
- SessionStoreManager.stopPeriodicSave();
-
- // Opt out of calendar promotion so we don't show the "ligthing now
- // integrated" notification bar (which gives us unexpected heights).
- Services.prefs.setBoolPref("calendar.integration.notify", false);
-}
-
-function teardownModule(module) {
- folderA.server.rootFolder.propagateDelete(folderA, true, null);
- folderB.server.rootFolder.propagateDelete(folderB, true, null);
- Services.prefs.clearUserPref("calendar.integration.notify");
-}
-
-function test_periodic_session_persistence_simple() {
- // delete the session file if it exists
- let sessionFile = SessionStoreManager.sessionFile;
- if (sessionFile.exists()) {
- sessionFile.remove(false);
- }
-
- utils.waitFor(() => !sessionFile.exists(), "session file should not exist");
-
- // change some state to guarantee the file will be recreated
- // if periodic session persistence works
- be_in_folder(folderA);
-
- // if periodic session persistence is working, the file should be
- // re-created
- SessionStoreManager._saveState();
- waitForFileRefresh();
-}
-
-function test_periodic_nondirty_session_persistence() {
- // This changes state.
- be_in_folder(folderB);
-
- SessionStoreManager._saveState();
- waitForFileRefresh();
-
- // delete the session file
- let sessionFile = SessionStoreManager.sessionFile;
- sessionFile.remove(false);
-
- // Since the state of the session hasn't changed since last _saveState(),
- // the session file should not be re-created.
- SessionStoreManager._saveState();
- controller.sleep(kSaveDelayMs + asyncFileWriteDelayMS);
-
- utils.waitFor(() => !sessionFile.exists(), "session file should not exist");
-}
-
-function test_single_3pane_periodic_session_persistence() {
- be_in_folder(folderA);
-
- // get the state object. this assumes there is one and only one
- // 3pane window.
- let mail3PaneWindow = Services.wm.getMostRecentWindow("mail:3pane");
- let state = mail3PaneWindow.getWindowStateForSessionPersistence();
-
- SessionStoreManager._saveState();
- waitForFileRefresh();
-
- // load the saved state from disk
- let loadedState = readFile();
- assert_true(loadedState, "previously saved state should be non-null");
-
- // get the state object for the one and only one 3pane window
- let windowState = loadedState.windows[0];
- assert_true(
- JSON.stringify(windowState) == JSON.stringify(state),
- "saved state and loaded state should be equal"
- );
-}
-
-function test_restore_single_3pane_persistence() {
- be_in_folder(folderA);
- toggle_message_pane();
- assert_message_pane_hidden();
-
- // get the state object. this assumes there is one and only one
- // 3pane window.
- let mail3PaneWindow = Services.wm.getMostRecentWindow("mail:3pane");
-
- // make sure we have a different window open, so that we don't start shutting
- // down just because the last window was closed
- let abwc = openAddressBook();
-
- // close the 3pane window
- close_window(new mozmill.controller.MozMillController(mail3PaneWindow));
- // Wait for window close async session write to finish.
- controller.sleep(asyncFileWriteDelayMS);
-
- mc = open3PaneWindow();
- set_mc(mc);
- be_in_folder(folderA);
- assert_message_pane_hidden();
- // restore message pane.
- toggle_message_pane();
-
- // We don't need the address book window any more.
- plan_for_window_close(abwc);
- abwc.window.close();
- wait_for_window_close();
-}
-
-function test_restore_single_3pane_persistence_again() {
- // test that repeating the save w/o changing the state restores
- // correctly.
- test_restore_single_3pane_persistence();
-}
-
-function test_message_pane_height_persistence() {
- be_in_folder(folderA);
- assert_message_pane_visible();
- assert_pane_layout(kClassicMailLayout);
-
- // Get the state object. This assumes there is one and only one
- // 3pane window.
- let mail3PaneWindow = Services.wm.getMostRecentWindow("mail:3pane");
-
- let oldHeight = mc.e("messagepaneboxwrapper").clientHeight;
- let minHeight = Math.floor(
- mc.e("messagepaneboxwrapper").getAttribute("minheight")
- );
- let newHeight = Math.floor((minHeight + oldHeight) / 2);
- let diffHeight = oldHeight - newHeight;
-
- assert_not_equals(
- oldHeight,
- newHeight,
- "To really perform a test the new message pane height should be " +
- "should be different from the old one but they are the same: " +
- newHeight
- );
-
- _move_splitter(mc.e("threadpane-splitter"), 0, diffHeight);
-
- // Check that the moving of the threadpane-splitter resulted in the correct height.
- let actualHeight = mc.e("messagepaneboxwrapper").clientHeight;
-
- assert_equals(
- newHeight,
- actualHeight,
- "The message pane height should be " +
- newHeight +
- ", but is actually " +
- actualHeight +
- ". The oldHeight was: " +
- oldHeight
- );
-
- // Make sure we have a different window open, so that we don't start shutting
- // down just because the last window was closed.
- let abwc = openAddressBook();
-
- // The 3pane window is closed.
- close_window(new mozmill.controller.MozMillController(mail3PaneWindow));
- // Wait for window close async session write to finish.
- controller.sleep(asyncFileWriteDelayMS);
-
- mc = open3PaneWindow();
- set_mc(mc);
- be_in_folder(folderA);
- assert_message_pane_visible();
-
- actualHeight = mc.e("messagepaneboxwrapper").clientHeight;
-
- assert_equals(
- newHeight,
- actualHeight,
- "The message pane height should be " +
- newHeight +
- ", but is actually " +
- actualHeight +
- ". The oldHeight was: " +
- oldHeight
- );
-
- // The old height is restored.
- _move_splitter(mc.e("threadpane-splitter"), 0, -diffHeight);
-
- // The 3pane window is closed.
- close_window(mc);
- // Wait for window close async session write to finish.
- controller.sleep(asyncFileWriteDelayMS);
-
- mc = open3PaneWindow();
- set_mc(mc);
- be_in_folder(folderA);
- assert_message_pane_visible();
-
- actualHeight = mc.e("messagepaneboxwrapper").clientHeight;
- assert_equals(
- oldHeight,
- actualHeight,
- "The message pane height should be " +
- oldHeight +
- ", but is actually " +
- actualHeight
- );
-
- // We don't need the address book window any more.
- plan_for_window_close(abwc);
- abwc.window.close();
- wait_for_window_close();
-}
-
-function test_message_pane_width_persistence() {
- be_in_folder(folderA);
- assert_message_pane_visible();
-
- // At the beginning we are in classic layout. We will switch to
- // vertical layout to test the width, and then back to classic layout.
- assert_pane_layout(kClassicMailLayout);
- set_pane_layout(kVerticalMailLayout);
- assert_pane_layout(kVerticalMailLayout);
-
- // Get the state object. This assumes there is one and only one
- // 3pane window.
- let mail3PaneWindow = Services.wm.getMostRecentWindow("mail:3pane");
-
- let oldWidth = mc.e("messagepaneboxwrapper").clientWidth;
- let minWidth = Math.floor(
- mc.e("messagepaneboxwrapper").getAttribute("minwidth")
- );
- let newWidth = Math.floor((minWidth + oldWidth) / 2);
- let diffWidth = oldWidth - newWidth;
-
- assert_not_equals(
- newWidth,
- oldWidth,
- "To really perform a test the new message pane width should be " +
- "should be different from the old one but they are the same: " +
- newWidth
- );
-
- // We move the threadpane-splitter and not the folderpane_splitter because
- // we are in vertical layout.
- _move_splitter(mc.e("threadpane-splitter"), diffWidth, 0);
- // Check that the moving of the folderpane_splitter resulted in the correct width.
- let actualWidth = mc.e("messagepaneboxwrapper").clientWidth;
-
- // FIXME: For whatever reasons the new width is off by one pixel on Mac OSX
- // But this test case is not for testing moving around a splitter but for
- // persistency. Therefore it is enough if the actual width is equal to the
- // the requested width plus/minus one pixel.
- assert_equals_fuzzy(
- newWidth,
- actualWidth,
- 1,
- "The message pane width should be " +
- newWidth +
- ", but is actually " +
- actualWidth +
- ". The oldWidth was: " +
- oldWidth
- );
- newWidth = actualWidth;
-
- // Make sure we have a different window open, so that we don't start shutting
- // down just because the last window was closed
- let abwc = openAddressBook();
-
- // The 3pane window is closed.
- close_window(new mozmill.controller.MozMillController(mail3PaneWindow));
- // Wait for window close async session write to finish.
- controller.sleep(asyncFileWriteDelayMS);
-
- mc = open3PaneWindow();
- set_mc(mc);
- be_in_folder(folderA);
- assert_message_pane_visible();
- assert_pane_layout(kVerticalMailLayout);
-
- actualWidth = mc.e("messagepaneboxwrapper").clientWidth;
- assert_equals(
- newWidth,
- actualWidth,
- "The message pane width should be " +
- newWidth +
- ", but is actually " +
- actualWidth
- );
-
- // The old width is restored.
- _move_splitter(mc.e("threadpane-splitter"), -diffWidth, 0);
- actualWidth = mc.e("messagepaneboxwrapper").clientWidth;
-
- // FIXME: For whatever reasons the new width is off by two pixels on Mac OSX
- // But this test case is not for testing moving around a splitter but for
- // persistency. Therefore it is enough if the actual width is equal to the
- // the requested width plus/minus two pixels.
- assert_equals_fuzzy(
- oldWidth,
- actualWidth,
- 2,
- "The message pane width should be " +
- oldWidth +
- ", but is actually " +
- actualWidth
- );
- oldWidth = actualWidth;
-
- // The 3pane window is closed.
- close_window(mc);
- // Wait for window close async session write to finish.
- controller.sleep(asyncFileWriteDelayMS);
-
- mc = open3PaneWindow();
- set_mc(mc);
- be_in_folder(folderA);
- assert_message_pane_visible();
- assert_pane_layout(kVerticalMailLayout);
-
- actualWidth = mc.e("messagepaneboxwrapper").clientWidth;
- assert_equals(
- oldWidth,
- actualWidth,
- "The message pane width should be " +
- oldWidth +
- ", but is actually " +
- actualWidth
- );
-
- // The layout is reset to classical mail layout.
- set_pane_layout(kClassicMailLayout);
- assert_pane_layout(kClassicMailLayout);
-
- // We don't need the address book window any more.
- plan_for_window_close(abwc);
- abwc.window.close();
- wait_for_window_close();
-}
-
-function test_multiple_3pane_periodic_session_persistence() {
- // open a few more 3pane windows
- for (var i = 0; i < 3; ++i) {
- open3PaneWindow();
- }
-
- // then get the state objects for each window
- let state = [];
- let enumerator = Services.wm.getEnumerator("mail:3pane");
- while (enumerator.hasMoreElements()) {
- state.push(enumerator.getNext().getWindowStateForSessionPersistence());
- }
-
- SessionStoreManager._saveState();
- waitForFileRefresh();
-
- // load the saved state from disk
- let loadedState = readFile();
- assert_true(loadedState, "previously saved state should be non-null");
-
- assert_equals(
- loadedState.windows.length,
- state.length,
- "number of windows in saved state and loaded state should be equal"
- );
-
- for (let i = 0; i < state.length; ++i) {
- assert_true(
- JSON.stringify(loadedState.windows[i]) == JSON.stringify(state[i]),
- "saved state and loaded state should be equal"
- );
- }
-
- // close all but one 3pane window
- enumerator = Services.wm.getEnumerator("mail:3pane");
- while (enumerator.hasMoreElements()) {
- let window = enumerator.getNext();
- if (enumerator.hasMoreElements()) {
- window.close();
- }
- }
-}
-
-async function test_bad_session_file_simple() {
- // forcefully write a bad session file
- let data = "BAD SESSION FILE";
- let fos = FileUtils.openSafeFileOutputStream(SessionStoreManager.sessionFile);
- fos.write(data, data.length);
- FileUtils.closeSafeFileOutputStream(fos);
-
- // tell the session store manager to try loading the bad session file.
- // NOTE: periodic session persistence is not enabled in this test
- SessionStoreManager._store = null;
- await SessionStoreManager._loadSessionFile();
-
- // since the session file is bad, the session store manager's state field
- // should be null
- assert_false(
- SessionStoreManager._initialState,
- "saved state is bad so state object should be null"
- );
-
- // The bad session file should now not exist.
- utils.waitFor(
- () => !SessionStoreManager.sessionFile.exists(),
- "session file should now not exist"
- );
-}
-
-function test_clean_shutdown_session_persistence_simple() {
- // open a few more 3pane windows
- for (var i = 0; i < 3; ++i) {
- open3PaneWindow();
- }
-
- // make sure we have a different window open, so that we don't start shutting
- // down just because the last window was closed
- let abwc = openAddressBook();
-
- // close all the 3pane windows
- let lastWindowState = null;
- let enumerator = Services.wm.getEnumerator("mail:3pane");
- while (enumerator.hasMoreElements()) {
- let window = enumerator.getNext();
- if (!enumerator.hasMoreElements()) {
- lastWindowState = window.getWindowStateForSessionPersistence();
- }
-
- close_window(new mozmill.controller.MozMillController(window));
- }
-
- // Wait for session file to be created (removed in prior test) after
- // all 3pane windows close and for session write to finish.
- waitForFileRefresh();
-
- // load the saved state from disk
- let loadedState = readFile();
- assert_true(loadedState, "previously saved state should be non-null");
-
- assert_equals(
- loadedState.windows.length,
- 1,
- "only the state of the last 3pane window should have been saved"
- );
-
- // get the state object for the one and only one 3pane window
- let windowState = loadedState.windows[0];
- assert_true(
- JSON.stringify(windowState) == JSON.stringify(lastWindowState),
- "saved state and loaded state should be equal"
- );
-
- open3PaneWindow();
-
- // We don't need the address book window any more.
- plan_for_window_close(abwc);
- abwc.window.close();
- wait_for_window_close();
-}
-
-/*
- * A set of private helper functions for drag'n'drop
- * These functions are inspired by tabmail/test-tabmail-dragndrop.js
- */
-
-function _move_splitter(aSplitter, aDiffX, aDiffY) {
- // catch the splitter in the middle
- let rect = aSplitter.getBoundingClientRect();
- let middleX = Math.round(rect.width / 2);
- let middleY = Math.round(rect.height / 2);
- EventUtils.synthesizeMouse(
- aSplitter,
- middleX,
- middleY,
- { type: "mousedown" },
- mc.window
- );
- EventUtils.synthesizeMouse(
- aSplitter,
- aDiffX + middleX,
- aDiffY + middleY,
- { type: "mousemove" },
- mc.window
- );
- // release the splitter
- EventUtils.synthesizeMouse(aSplitter, 0, 0, { type: "mouseup" }, mc.window);
-}
-
-/**
- * Helper function that checks the fuzzy equivalence of two numeric
- * values against some given tolerance.
- *
- * @param aLeft one value to check equivalence with
- * @param aRight the other value to check equivalence with
- * @param aTolerance how fuzzy can our equivalence be?
- * @param aMessage the message to give off if we're outside of tolerance.
- */
-function assert_equals_fuzzy(aLeft, aRight, aTolerance, aMessage) {
- assert_true(Math.abs(aLeft - aRight) <= aTolerance, aMessage);
-}
-
-// XXX todo
-// - crash test: not sure if this test should be here. restoring a crashed
-// session depends on periodically saved session data (there is
-// already a test for this). session restoration tests do not
-// belong here. see test-message-pane-visibility.
-// when testing restoration in test-message-pane-visibility, also
-// include test of bad session file.
-// ..............maybe we should move all session restoration related tests
-// ..............here.
deleted file mode 100644
index 14353b3786018ed39e9a4f1c4049c6bf7435d865..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
--- a/mail/test/mozmill/smime/README.md
+++ /dev/null
@@ -1,5 +0,0 @@
-S/MIME Mozmill test certificates and messages
-=============================================
-
-The test data in this directory can be refreshed by executing script
-local-gen.sh found in comm/mailnews/test/data/smime
deleted file mode 100644
--- a/mail/test/mozmill/smime/TestCA.pem
+++ /dev/null
@@ -1,21 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIDdTCCAl2gAwIBAgIBATANBgkqhkiG9w0BAQsFADBkMQswCQYDVQQGEwJVUzET
-MBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzESMBAG
-A1UEChMJQk9HVVMgTlNTMRQwEgYDVQQDEwtOU1MgVGVzdCBDQTAgFw0xOTA3MDMx
-ODA5NThaGA8yMDY5MDcwMzE4MDk1OFowZDELMAkGA1UEBhMCVVMxEzARBgNVBAgT
-CkNhbGlmb3JuaWExFjAUBgNVBAcTDU1vdW50YWluIFZpZXcxEjAQBgNVBAoTCUJP
-R1VTIE5TUzEUMBIGA1UEAxMLTlNTIFRlc3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUA
-A4IBDwAwggEKAoIBAQC8FkTcBeE9WV4u10vz/XavYkImH1bp1w87toLH9avonCjK
-oCXE+1d3lvd8rY/wCVV4N4Rrw3ED/Jm4gK117fbvN8sRexDqmwPYbw3KkoVKtqDv
-fxy2omTYIkzVH9Z+wBpWu//ce10gNeARUIoBNc4rRJhv7qIqY4NjZr1suwLZP82N
-jtLu4vq9QSTnFle1DRqjdcCxehF9scY5rTgw9Ua4pwkZwi3Akt/tUYU4iEeD2kx5
-NggTbnRUDrhOOFYZ3R+KeyAl7/drFBbT8Ze8FpnvsSZzcLORccIhH98HHZoz2oMT
-lGK0ODDCnhaWfsFQ+hKM/bLk1AsA5Rv0WSbYj20bAgMBAAGjMDAuMBEGCWCGSAGG
-+EIBAQQEAwIABzAMBgNVHRMEBTADAQH/MAsGA1UdDwQEAwIBBjANBgkqhkiG9w0B
-AQsFAAOCAQEArhnWDjcGcmRyl0VDBJck60b1WVuPGjJkoBU/Ywq4L8MTE/vD315v
-U4qxIZAg4K542F8fiA1D9C151AOzoEZgDmanSJ4vtmdbS14W5PSj4z2jhAGkIelk
-8NuzBYUORvCb7DoYX393USMTcC6MZp075J7mzULkiymsjoXSG12E3twjI1wNwh7f
-adk533+YtzrHyOe6JS8sMfs2luW89YJU9rFNc/DpnGiDrs66M5gIUj4m7IaJc2KT
-ZKmWdr114FuDz3Ntzpq1lG7WnhNVY4chiD0j7QstTtxTtZmh4kkmUCFz2ni20eOv
-Z3WpiiUawwHXuzrsBQBZKiCFULopmGFvZw==
------END CERTIFICATE-----
deleted file mode 100644
--- a/mail/test/mozmill/smime/multipart-alternative.eml
+++ /dev/null
@@ -1,41 +0,0 @@
-MIME-Version: 1.0
-From: Alice <alice@example.com>
-To: Bob <bob@example.com>
-Subject: a message
-Content-Type: multipart/alternative; boundary="--------BOUNDARY"
-
-----------BOUNDARY
-Content-Type: application/pkcs7-mime; smime-type=enveloped-data
-Content-Transfer-Encoding: base64
-
-MIAGCSqGSIb3DQEHA6CAMIACAQAxggGFMIIBgQIBADBpMGQxCzAJBgNVBAYTAlVT
-MRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRIw
-EAYDVQQKEwlCT0dVUyBOU1MxFDASBgNVBAMTC05TUyBUZXN0IENBAgEoMA0GCSqG
-SIb3DQEBAQUABIIBAJUcHjxrchh05IJiFogCoKOAWpwuUGnnpyxbu6sA489VJeWB
-TIgC5AtmScBpFCRb+OFnFnqYZzRy8gjx5WOXPS/XUw6AK1z3mSJ0ZakMgUv4fYBH
-ZMHcQp4wh9hbQBjzfIXSdy7M04/H8UlRgNle/QcldKPB6sk367ht+aDadTPahEhi
-/q7AC8mxaUINRmSIiPAA3PeE4HdLnoebdAyjXJQocLkshuMPPe9xJc0ZrhxStOSZ
-hntgLH63BevYBlHhnoqzlDy1NW5xt8ckJPqKa9LkmRwUe779ezP7era0t1hpx0Vx
-6AVjN71aoNCuADPb8A7kvI200rZZ1jARButd/ukwgAYJKoZIhvcNAQcBMB0GCWCG
-SAFlAwQBAgQQZo12DT01yTXtxZ2/+fjc1aCABIGQruHZ53yEsf5U2co6ksduFP/j
-Db28zsZ6fAe+QR7/Z8mM9EMWZ/c7FnnEj/7sG5MQO6WwmzZPuB9KwX2uUvE2oMyo
-ZvRCK5IRjxm2CQPxnwJfiITyFh7szjeS71HBKSI+mIY5FJTvCnlztc2q3d2vsKqk
-Ow3PLNpw8QtMTsDnO8R0XUh99bMkbdmHAtaQZ7hDBBBmo9Fim4/xlH4rP/wvybWg
-AAAAAAAAAAAAAA==
-----------BOUNDARY
-Content-Type: application/pkcs7-mime; smime-type=enveloped-data
-Content-Transfer-Encoding: base64
-
-MIAGCSqGSIb3DQEHA6CAMIACAQAxggGFMIIBgQIBADBpMGQxCzAJBgNVBAYTAlVT
-MRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRIw
-EAYDVQQKEwlCT0dVUyBOU1MxFDASBgNVBAMTC05TUyBUZXN0IENBAgEoMA0GCSqG
-SIb3DQEBAQUABIIBAD7d8RoWBfVyg7ETewBx6l1c3VK7mqIhKRcNx0UuwPwOfgxo
-8TrC8cEM15rHpB5TNexekmOfxhXOJ0d72JMIAbWc4Hjv6OtHm9tjt5YLDmNWb/W4
-07PdifAaOFEI8t3qersm2HCmyalPQVxURr4fJK5MXscK6fO3c8HR2VmdjNb+6UoY
-sVpQ3/xoD/pW3/FbvHB6x4zdnBFujHodgfomplEsWeBoK61qI3NUY2m8CgelzRAW
-YxbkZzkHhcaG4BrqisowK/BCSz7r2uBRMsH3PEegV7LGt2gvLxpZb42VyriDXV2k
-0tnU5oawZ3ks5M1p488tUeGWuRh/HfAYdoQJ0hEwgAYJKoZIhvcNAQcBMB0GCWCG
-SAFlAwQBAgQQSetjLFcVadme5s5iIksNT6CABEBis4nUbp0jvtFhfHfZ6j4wbp3R
-3zbZZyPFdsUktzkF88LEwAGTouYBu7Arcz/eTWOKomWk7s35VBDmCGNNMYAVBBCx
-dJCvX4o6dZ2krYZx7OAjAAAAAAAAAAAAAA==
-----------BOUNDARY
deleted file mode 100644
--- a/mail/test/mozmill/smime/test-smime-multipart-alternative.js
+++ /dev/null
@@ -1,92 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Test that a reply to a multipart/alternative message with two
- * encrypted parts doesn't leak the secret plaintext from the second
- * part.
- */
-
-"use strict";
-
-var os = ChromeUtils.import("chrome://mozmill/content/stdlib/os.jsm");
-
-var {
- close_compose_window,
- get_msg_source,
- open_compose_with_reply,
-} = ChromeUtils.import("resource://testing-common/mozmill/ComposeHelpers.jsm");
-var {
- assert_false,
- be_in_folder,
- get_special_folder,
- open_message_from_file,
- press_delete,
- select_click_row,
- smimeUtils_ensureNSS,
- smimeUtils_loadCertificateAndKey,
- smimeUtils_loadPEMCertificate,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { close_window } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var { MailServices } = ChromeUtils.import(
- "resource:///modules/MailServices.jsm"
-);
-
-var gDrafts;
-
-function setupModule(module) {
- gDrafts = get_special_folder(Ci.nsMsgFolderFlags.Drafts, true);
-
- Services.prefs.setBoolPref("mail.identity.id1.compose_html", true);
-}
-
-function get_file_for_path(path) {
- return os.getFileForPath(os.abspath(path, os.getFileForPath(__file__)));
-}
-
-function test_multipart_alternative() {
- smimeUtils_ensureNSS();
- smimeUtils_loadPEMCertificate(
- get_file_for_path("./TestCA.pem"),
- Ci.nsIX509Cert.CA_CERT
- );
- smimeUtils_loadCertificateAndKey(get_file_for_path("./Bob.p12"));
-
- let msgc = open_message_from_file(
- get_file_for_path("./multipart-alternative.eml")
- );
-
- let cwc = open_compose_with_reply(msgc);
-
- close_window(msgc);
-
- // Now save the message as a draft.
- cwc.keypress(null, "s", { shiftKey: false, accelKey: true });
- close_compose_window(cwc);
-
- // Now check the message content in the drafts folder.
- be_in_folder(gDrafts);
- let message = select_click_row(0);
- let messageContent = get_msg_source(message);
-
- // Check for a single line that contains text and make sure there is a
- // space at the end for a flowed reply.
- assert_false(
- messageContent.includes("SECRET-TEXT"),
- "Secret text was found, but shouldn't be there."
- );
-
- // Delete the outgoing message.
- press_delete();
-}
-
-function teardownModule() {
- Services.prefs.clearUserPref("mail.identity.id1.compose_html");
-}
deleted file mode 100644
--- a/mail/test/mozmill/startup-firstrun/test-menubar-collapsed.js
+++ /dev/null
@@ -1,52 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests that the main menu will be collapsed by default if Thunderbird starts
- * with no accounts created.
- */
-
-"use strict";
-
-var { assert_equals, mc } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { close_window, wait_for_existing_window } = ChromeUtils.import(
- "resource://testing-common/mozmill/WindowHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-function test_main_menu_collapsed() {
- // Due to random oranges on slower machines, we need to ensure that startup
- // is complete before running this test.
- let done = false;
- let observer = {
- observe(aSubject, aTopic, aData) {
- if (aTopic == "mail-startup-done") {
- done = true;
- }
- },
- };
- Services.obs.addObserver(observer, "mail-startup-done");
-
- // Since no accounts were set up, and the account provisioner was disabled
- // in prefs.js, the wizard will show up. Find it, and close it. This will
- // cause mail-startup-done to eventually be fired.
- let wizard = wait_for_existing_window("mail:autoconfig");
- close_window(wizard);
-
- // Spin the event loop until mail-startup-done is fired.
- mc.waitFor(() => done);
-
- let mainMenu = mc.e("mail-toolbar-menubar2");
- assert_equals(
- mainMenu.getAttribute("autohide"),
- "true",
- "The main menu should have the autohide attribute set to true."
- );
-
- Services.obs.removeObserver(observer, "mail-startup-done");
-}
-test_main_menu_collapsed.EXCLUDED_PLATFORMS = ["Darwin"];
deleted file mode 100644
--- a/mail/test/mozmill/startup-firstrun/wrapper.py
+++ /dev/null
@@ -1,16 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-# For these tests, we need to disable the account provisioner, or
-# else it will spawn immediately and block before we have a chance to run
-# any Mozmill tests.
-
-# We don't want any accounts for these tests.
-NO_ACCOUNTS = True
-# Do not force enable main menu bar (keep the default).
-DEFAULT_MENUBAR = True
-
-PREFS = {
- "mail.provider.enabled": False,
-}
deleted file mode 100644
--- a/mail/test/mozmill/subscribe/test-subscribe-news-filter.js
+++ /dev/null
@@ -1,58 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/* Test that the subscribe window for news servers has working autocomplete. */
-
-"use strict";
-
-var utils = ChromeUtils.import("chrome://mozmill/content/modules/utils.jsm");
-
-var {
- NNTP_PORT,
- setupLocalServer,
- setupNNTPDaemon,
- shutdownNNTPServer,
- startupNNTPServer,
-} = ChromeUtils.import("resource://testing-common/mozmill/NNTPHelpers.jsm");
-var {
- check_newsgroup_displayed,
- enter_text_in_search_box,
- open_subscribe_window_from_context_menu,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/SubscribeWindowHelpers.jsm"
-);
-
-/**
- * Checks that the filter in the subscribe window works correctly
- * (shows only newsgroups matching all of several search strings
- * separated by whitespace)
- */
-function test_subscribe_newsgroup_filter() {
- var daemon = setupNNTPDaemon();
- var remoteServer = startupNNTPServer(daemon, NNTP_PORT);
- let server = setupLocalServer(NNTP_PORT);
- let rootFolder = server.rootFolder;
- open_subscribe_window_from_context_menu(rootFolder, filter_test_helper);
- shutdownNNTPServer(remoteServer);
-}
-
-/**
- * Helper function (callback), needed because the subscribe window is modal.
- * @param swc Controller for the subscribe window
- */
-function filter_test_helper(swc) {
- enter_text_in_search_box(swc, "subscribe empty");
- utils.waitFor(
- () => check_newsgroup_displayed(swc, "test.subscribe.empty"),
- "test.subscribe.empty not in the list"
- );
- utils.waitFor(
- () => !check_newsgroup_displayed(swc, "test.empty"),
- "test.empty is in the list, but should not be"
- );
- utils.waitFor(
- () => !check_newsgroup_displayed(swc, "test.subscribe.simple"),
- "test.subscribe.simple is in the list, but should not be"
- );
-}
deleted file mode 100644
--- a/mail/test/mozmill/tabmail/test-tabmail-closing.js
+++ /dev/null
@@ -1,127 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Test tabmail behaviour when tabs close.
- */
-
-"use strict";
-
-var {
- assert_equals,
- assert_selected_tab,
- be_in_folder,
- collapse_all_threads,
- create_folder,
- make_display_threaded,
- make_new_sets_in_folder,
- mc,
- open_selected_message_in_new_tab,
- open_selected_messages,
- select_click_row,
- switch_tab,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var gFolder;
-
-var MSGS_PER_THREAD = 3;
-
-function setupModule(module) {
- gFolder = create_folder("test-tabmail-closing folder");
- make_new_sets_in_folder(gFolder, [{ msgsPerThread: MSGS_PER_THREAD }]);
-}
-
-/**
- * Test that if we open up a message in a tab from the inbox tab, that
- * if we immediately close that tab, we switch back to the inbox tab.
- */
-function test_closed_single_message_tab_returns_to_inbox() {
- be_in_folder(gFolder);
- make_display_threaded();
- let inboxTab = mc.tabmail.currentTabInfo;
-
- select_click_row(0);
- // Open a message in a new tab...
- open_selected_message_in_new_tab(false);
-
- // Open a second message in a new tab...
- switch_tab(0);
- select_click_row(1);
- open_selected_message_in_new_tab(false);
-
- // Close the second tab
- mc.tabmail.closeTab(2);
-
- // We should have gone back to the inbox tab
- assert_selected_tab(inboxTab);
-
- // Close the first tab
- mc.tabmail.closeTab(1);
-}
-
-/**
- * Test that if we open up some message tabs from the inbox tab, and then
- * switch around in those tabs, closing the tabs doesn't immediately jump
- * you back to the inbox tab.
- */
-function test_does_not_go_to_opener_if_switched() {
- be_in_folder(gFolder);
- make_display_threaded();
-
- select_click_row(0);
- // Open a message in a new tab...
- open_selected_message_in_new_tab(false);
-
- // Open a second message in a new tab...
- switch_tab(0);
- select_click_row(1);
- open_selected_message_in_new_tab(false);
-
- // Switch to the first tab
- switch_tab(1);
- let firstTab = mc.tabmail.currentTabInfo;
-
- // Switch back to the second tab
- switch_tab(2);
-
- // Close the second tab
- mc.tabmail.closeTab(2);
-
- // We should have gone back to the second tab
- assert_selected_tab(firstTab);
-
- // Close the first tab
- mc.tabmail.closeTab(1);
-}
-
-/**
- * Test that if we open a whole thread up in message tabs, closing
- * the last message tab takes us to the second last message tab as opposed
- * to the inbox tab.
- */
-function test_opening_thread_in_tabs_closing_behaviour() {
- be_in_folder(gFolder);
- make_display_threaded();
- collapse_all_threads();
-
- // Open a thread as a series of message tabs.
- select_click_row(0);
- open_selected_messages(mc);
-
- // At this point, the last message tab should be selected already. We
- // close that tab, and the second last message tab should be selected.
- // We should close that tab, and the third last tab should be selected,
- // etc.
- for (let i = MSGS_PER_THREAD; i > 0; --i) {
- let previousTab = mc.tabmail.tabContainer.getItemAtIndex(i - 1);
- mc.tabmail.closeTab(i);
- assert_equals(
- previousTab,
- mc.tabmail.tabContainer.selectedItem,
- "Expected tab at index " + (i - 1) + " to be selected."
- );
- }
-}
deleted file mode 100644
--- a/mail/test/mozmill/tabmail/test-tabmail-customize.js
+++ /dev/null
@@ -1,132 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * Tests customization features of the tabs toolbar.
- */
-
-"use strict";
-
-var { CustomizeDialogHelper } = ChromeUtils.import(
- "resource://testing-common/mozmill/CustomizationHelpers.jsm"
-);
-var {
- assert_equals,
- assert_not_equals,
- mc,
- wait_for_popup_to_open,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var { drag_n_drop_element } = ChromeUtils.import(
- "resource://testing-common/mozmill/MouseEventHelpers.jsm"
-);
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var gCDHelper;
-
-function setupModule(module) {
- gCDHelper = new CustomizeDialogHelper(
- "mail-toolbar-menubar2",
- "CustomizeMailToolbar",
- "mailnews:customizeToolbar"
- );
-}
-
-function teardownModule(module) {
- // Let's reset any and all of our changes to the toolbar
- gCDHelper.restoreDefaultButtons(mc);
-}
-
-/**
- * Test that we can access the customize context menu by right
- * clicking on the tabs toolbar.
- */
-function test_open_context_menu() {
- // First, ensure that the context menu is closed.
- let contextPopup = mc.e("toolbar-context-menu");
- assert_not_equals(contextPopup.state, "open");
-
- // Right click on the tab bar
- mc.rightClick(mc.eid("tabmail-tabs"));
-
- // Ensure that the popup opened
- wait_for_popup_to_open(contextPopup);
-}
-
-/**
- * Test that, when customizing the toolbars, if the user drags an item onto
- * the tab bar, they're redirected to the toolbar directly to the right of
- * the tab bar.
- */
-function test_redirects_toolbarbutton_drops() {
- Services.prefs.setBoolPref("toolkit.customization.unsafe_drag_events", true);
- // Restore the default buttons to get defined starting conditions.
- gCDHelper.restoreDefaultButtons(mc);
-
- let tabbar = mc.e("tabmail-tabs");
- let toolbar = mc.e("tabbar-toolbar");
-
- // First, let's open up the customize toolbar window.
- let ctw = gCDHelper.open(mc);
-
- // Let's grab some items from the customize window, and try dropping
- // them on the tab bar
- [
- "wrapper-button-replyall",
- "wrapper-button-replylist",
- "wrapper-button-forward",
- "wrapper-button-archive",
- ].forEach(function(aButtonId) {
- let button = ctw.e(aButtonId);
-
- drag_n_drop_element(
- button,
- ctw.window,
- tabbar,
- mc.window,
- 0.5,
- 0.5,
- ctw.window
- );
-
- // Now let's check to make sure that this button is now the first
- // item in the tab bar toolbar.
- assert_equals(
- toolbar.firstElementChild.id,
- aButtonId,
- "Button was not added as first child!"
- );
- });
-
- // Ok, now let's try to grab some toolbar buttons from mail-bar3, and
- // make sure we can drop those on the tab bar too.
- ["button-getmsg", "button-newmsg", "button-address", "button-tag"].forEach(
- function(aButtonId) {
- let button = mc.e(aButtonId);
-
- drag_n_drop_element(
- button,
- mc.window,
- tabbar,
- mc.window,
- 0.5,
- 0.5,
- mc.window
- );
-
- // Now let's check to make sure that this button is now the first
- // item in the tab bar toolbar.
- assert_equals(
- toolbar.firstElementChild.id,
- "wrapper-" + aButtonId,
- "Button was not added as first child!"
- );
- }
- );
-
- gCDHelper.close(ctw);
- Services.prefs.clearUserPref("toolkit.customization.unsafe_drag_events");
-}
deleted file mode 100644
--- a/mail/test/mozmill/tabmail/test-tabmail-dragndrop.js
+++ /dev/null
@@ -1,510 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-/*
- * Test rearanging tabs via drag'n'drop.
- */
-
-var elib = ChromeUtils.import(
- "chrome://mozmill/content/modules/elementslib.jsm"
-);
-var EventUtils = ChromeUtils.import(
- "chrome://mozmill/content/stdlib/EventUtils.jsm"
-);
-
-var {
- assert_equals,
- assert_folder_selected_and_displayed,
- assert_number_of_tabs_open,
- assert_row_visible,
- assert_selected_and_displayed,
- assert_true,
- be_in_folder,
- close_popup,
- create_folder,
- display_message_in_folder_tab,
- make_new_sets_in_folder,
- mc,
- open_selected_message_in_new_tab,
- select_click_row,
- switch_tab,
- wait_for_message_display_completion,
- wait_for_popup_to_open,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-var {
- drag_n_drop_element,
- synthesize_drag_end,
- synthesize_drag_start,
- synthesize_drag_over,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/MouseEventHelpers.jsm"
-);
-var {
- close_window,
- plan_for_new_window,
- wait_for_new_window,
-} = ChromeUtils.import("resource://testing-common/mozmill/WindowHelpers.jsm");
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var folder;
-var msgHdrsInFolder = [];
-
-// The number of messages in folder.
-var NUM_MESSAGES_IN_FOLDER = 15;
-
-function setupModule(module) {
- folder = create_folder("MessageFolder");
- make_new_sets_in_folder(folder, [{ count: NUM_MESSAGES_IN_FOLDER }]);
-}
-
-/**
- * Verifies our test environment is setup correctly and initializes
- * all global variables.
- */
-function test_tab_reorder_setup_globals() {
- be_in_folder(folder);
- // Scroll to the top
- mc.folderDisplay.ensureRowIsVisible(0);
- let msgHdr = mc.dbView.getMsgHdrAt(1);
-
- display_message_in_folder_tab(msgHdr, false);
-
- // Check that the right message is displayed
- assert_number_of_tabs_open(1);
- assert_folder_selected_and_displayed(folder);
- assert_selected_and_displayed(msgHdr);
-
- assert_row_visible(1);
-
- // Initialize the globals we'll need for all our tests.
-
- // Stash messages into arrays for convenience. We do it this way so that the
- // order of messages in the arrays is the same as in the views.
- be_in_folder(folder);
- for (let i = 0; i < NUM_MESSAGES_IN_FOLDER; i++) {
- msgHdrsInFolder.push(mc.dbView.getMsgHdrAt(i));
- }
-
- // Mark all messages read
- folder.markAllMessagesRead(null);
-}
-
-/**
- * Tests reordering tabs by drag'n'drop within the tabbar
- *
- * It opens additional movable and closable tabs. The picks the first
- * movable tab and drops it onto the third movable tab.
- */
-function test_tab_reorder_tabbar() {
- // Ensure only one tab is open, otherwise our test most likey fail anyway.
- mc.tabmail.closeOtherTabs(0);
- assert_number_of_tabs_open(1);
-
- be_in_folder(folder);
-
- // Open four tabs
- for (let idx = 0; idx < 4; idx++) {
- select_click_row(idx);
- open_selected_message_in_new_tab(true);
- }
-
- // Check if every thing is correctly initialized
- assert_number_of_tabs_open(5);
-
- assert_true(
- mc.tabmail.tabModes.message.tabs[0] == mc.tabmail.tabInfo[1],
- " tabMode.tabs and tabInfo out of sync"
- );
-
- assert_true(
- mc.tabmail.tabModes.message.tabs[1] == mc.tabmail.tabInfo[2],
- " tabMode.tabs and tabInfo out of sync"
- );
-
- assert_true(
- mc.tabmail.tabModes.message.tabs[2] == mc.tabmail.tabInfo[3],
- " tabMode.tabs and tabInfo out of sync"
- );
-
- // Start dragging the first tab
- switch_tab(1);
- assert_selected_and_displayed(msgHdrsInFolder[0]);
-
- let tab1 = mc.tabmail.tabContainer.allTabs[1];
- let tab3 = mc.tabmail.tabContainer.allTabs[3];
-
- drag_n_drop_element(
- tab1,
- mc.window,
- tab3,
- mc.window,
- 0.75,
- 0.0,
- mc.tabmail.tabContainer
- );
-
- wait_for_message_display_completion(mc);
-
- // if every thing went well...
- assert_number_of_tabs_open(5);
-
- // ... we should find tab1 at the third position...
- assert_equals(tab1, mc.tabmail.tabContainer.allTabs[3], "Moving tab1 failed");
- switch_tab(3);
- assert_selected_and_displayed(msgHdrsInFolder[0]);
-
- // ... while tab3 moves one up and gets second.
- assert_true(tab3 == mc.tabmail.tabContainer.allTabs[2], "Moving tab3 failed");
- switch_tab(2);
- assert_selected_and_displayed(msgHdrsInFolder[2]);
-
- // we have one "message" tab and three "folder" tabs, thus tabInfo[1-3] and
- // tabMode["message"].tabs[0-2] have to be same, otherwise something went
- // wrong while moving tabs around
- assert_true(
- mc.tabmail.tabModes.message.tabs[0] == mc.tabmail.tabInfo[1],
- " tabMode.tabs and tabInfo out of sync"
- );
-
- assert_true(
- mc.tabmail.tabModes.message.tabs[1] == mc.tabmail.tabInfo[2],
- " tabMode.tabs and tabInfo out of sync"
- );
-
- assert_true(
- mc.tabmail.tabModes.message.tabs[2] == mc.tabmail.tabInfo[3],
- " tabMode.tabs and tabInfo out of sync"
- );
-}
-
-/**
- * Tests drag'n'drop tab reordering between windows
- */
-function test_tab_reorder_window() {
- // Ensure only one tab is open, otherwise our test most likey fail anyway.
- mc.tabmail.closeOtherTabs(0);
- assert_number_of_tabs_open(1);
-
- let mc2 = null;
-
- be_in_folder(folder);
-
- // Open a new tab...
- select_click_row(1);
- open_selected_message_in_new_tab(false);
-
- assert_number_of_tabs_open(2);
-
- switch_tab(1);
- assert_selected_and_displayed(msgHdrsInFolder[1]);
-
- // ...and then a new 3 pane as our drop target.
- plan_for_new_window("mail:3pane");
-
- let args = { msgHdr: msgHdrsInFolder[3] };
- args.wrappedJSObject = args;
-
- let aWnd2 = Services.ww.openWindow(
- null,
- "chrome://messenger/content/messenger.xhtml",
- "",
- "all,chrome,dialog=no,status,toolbar",
- args
- );
-
- mc2 = wait_for_new_window("mail:3pane");
- wait_for_message_display_completion(mc2, true);
-
- // Double check if we are listening to the right window.
- assert_true(aWnd2 == mc2.window, "Opening Window failed");
-
- // Start dragging the first tab ...
- let tabA = mc.tabmail.tabContainer.allTabs[1];
- assert_true(tabA, "No movable Tab");
-
- // We drop onto the Folder Tab, it is guaranteed to exist.
- let tabB = mc2.tabmail.tabContainer.allTabs[0];
- assert_true(tabB, "No movable Tab");
-
- drag_n_drop_element(
- tabA,
- mc.window,
- tabB,
- mc2.window,
- 0.75,
- 0.0,
- mc.tabmail.tabContainer
- );
-
- wait_for_message_display_completion(mc2);
-
- assert_true(
- mc.tabmail.tabContainer.allTabs.length == 1,
- "Moving tab to new window failed, tab still in old window"
- );
-
- assert_true(
- mc2.tabmail.tabContainer.allTabs.length == 2,
- "Moving tab to new window failed, no new tab in new window"
- );
-
- assert_selected_and_displayed(mc2, msgHdrsInFolder[1]);
-}
-
-/**
- * Tests detaching tabs into windows via drag'n'drop
- */
-function test_tab_reorder_detach() {
- // Ensure only one tab is open, otherwise our test most likey fail anyway.
- mc.tabmail.closeOtherTabs(0);
- assert_number_of_tabs_open(1);
-
- let mc2 = null;
-
- be_in_folder(folder);
-
- // Open a new tab...
- select_click_row(2);
- open_selected_message_in_new_tab(false);
-
- assert_number_of_tabs_open(2);
-
- // ... if every thing works we should expect a new window...
- plan_for_new_window("mail:3pane");
-
- // ... now start dragging
-
- mc.tabmail.switchToTab(1);
-
- let tab1 = mc.tabmail.tabContainer.allTabs[1];
- let dropContent = mc.e("tabpanelcontainer");
-
- let dt = synthesize_drag_start(mc.window, tab1, mc.tabmail.tabContainer);
-
- synthesize_drag_over(mc.window, dropContent, dt);
-
- // notify tab1 drag has ended
- let dropRect = dropContent.getBoundingClientRect();
- synthesize_drag_end(mc.window, dropContent, tab1, dt, {
- screenX: dropContent.screenX + dropRect.width / 2,
- screenY: dropContent.screenY + dropRect.height / 2,
- });
-
- // ... and wait for the new window
- mc2 = wait_for_new_window("mail:3pane");
- wait_for_message_display_completion(mc2, true);
-
- assert_true(
- mc.tabmail.tabContainer.allTabs.length == 1,
- "Moving tab to new window failed, tab still in old window"
- );
-
- assert_true(
- mc2.tabmail.tabContainer.allTabs.length == 2,
- "Moving tab to new window failed, no new tab in new window"
- );
-
- assert_selected_and_displayed(mc2, msgHdrsInFolder[2]);
-}
-
-/**
- * Test undo of recently closed tabs.
- */
-function test_tab_undo() {
- // Ensure only one tab is open, otherwise our test most likey fail anyway.
- mc.tabmail.closeOtherTabs(0);
- assert_number_of_tabs_open(1);
-
- be_in_folder(folder);
-
- // Open five tabs...
- for (let idx = 0; idx < 5; idx++) {
- select_click_row(idx);
- open_selected_message_in_new_tab(true);
- }
-
- assert_number_of_tabs_open(6);
-
- switch_tab(2);
- assert_selected_and_displayed(msgHdrsInFolder[1]);
-
- mc.tabmail.closeTab(2);
- // This tab should not be added to recently closed tabs...
- // ... thus it can't be restored
- mc.tabmail.closeTab(2, true);
- mc.tabmail.closeTab(2);
-
- assert_number_of_tabs_open(3);
- assert_selected_and_displayed(mc, msgHdrsInFolder[4]);
-
- mc.tabmail.undoCloseTab();
- assert_number_of_tabs_open(4);
- assert_selected_and_displayed(mc, msgHdrsInFolder[3]);
-
- // msgHdrsInFolder[2] won't be restorend it was closed with disabled undo.
-
- mc.tabmail.undoCloseTab();
- assert_number_of_tabs_open(5);
- assert_selected_and_displayed(mc, msgHdrsInFolder[1]);
-}
-
-function _synthesizeRecentlyClosedMenu() {
- mc.rightClick(new elib.Elem(mc.tabmail.tabContainer.allTabs[1]));
-
- let tabContextMenu = mc.window.document.getElementById("tabContextMenu");
- wait_for_popup_to_open(tabContextMenu);
-
- let recentlyClosedTabs = tabContextMenu.querySelector(
- '[anonid="recentlyClosedTabs"]'
- );
-
- EventUtils.synthesizeMouse(recentlyClosedTabs, 5, 5, {}, mc.window);
- wait_for_popup_to_open(recentlyClosedTabs.menupopup);
-
- return recentlyClosedTabs;
-}
-
-function _teardownRecentlyClosedMenu() {
- let menu = mc.window.document.getElementById("tabContextMenu");
- close_popup(mc, new elib.Elem(menu));
-}
-
-/**
- * Tests the recently closed tabs menu.
- */
-function test_tab_recentlyClosed() {
- // Ensure only one tab is open, otherwise our test most likey fail anyway.
- mc.tabmail.closeOtherTabs(0, true);
- assert_number_of_tabs_open(1);
-
- // We start with a clean tab history.
- mc.tabmail.clearRecentlyClosedTabs();
- assert_equals(mc.tabmail.recentlyClosedTabs.length, 0);
-
- // The history is cleaned so let's open 15 tabs...
- be_in_folder(folder);
-
- for (let idx = 0; idx < 15; idx++) {
- select_click_row(idx);
- open_selected_message_in_new_tab(true);
- }
-
- assert_number_of_tabs_open(16);
-
- switch_tab(2);
- assert_selected_and_displayed(msgHdrsInFolder[1]);
-
- // ... and store the tab titles, to ensure they match with the menu items.
- let tabTitles = [];
- for (let idx = 0; idx < 16; idx++) {
- tabTitles.unshift(mc.tabmail.tabInfo[idx].title);
- }
-
- // Start the test by closing all tabs except the first two tabs...
- for (let idx = 0; idx < 14; idx++) {
- mc.tabmail.closeTab(2);
- }
-
- assert_number_of_tabs_open(2);
-
- // ...then open the context menu.
- let menu = _synthesizeRecentlyClosedMenu();
-
- // Check if the context menu was populated correctly...
- assert_true(menu.itemCount == 12, "Failed to populate context menu");
- for (let idx = 0; idx < 10; idx++) {
- assert_true(
- tabTitles[idx] == menu.getItemAtIndex(idx).label,
- "Tab Title does not match Menu item"
- );
- }
-
- // Restore the most recently closed tab
- EventUtils.synthesizeMouse(menu.getItemAtIndex(0), 5, 5, {}, mc.window);
- _teardownRecentlyClosedMenu();
-
- wait_for_message_display_completion(mc);
- assert_number_of_tabs_open(3);
- assert_selected_and_displayed(msgHdrsInFolder[14]);
-
- // The context menu should now contain one item less.
- _synthesizeRecentlyClosedMenu();
-
- assert_true(menu.itemCount == 11, "Failed to populate context menu");
- for (let idx = 0; idx < 9; idx++) {
- assert_true(
- tabTitles[idx + 1] == menu.getItemAtIndex(idx).label,
- "Tab Title does not match Menu item"
- );
- }
-
- // Now we restore an "random" tab.
- EventUtils.synthesizeMouse(menu.getItemAtIndex(5), 5, 5, {}, mc.window);
- _teardownRecentlyClosedMenu();
-
- wait_for_message_display_completion(mc);
- assert_number_of_tabs_open(4);
- assert_selected_and_displayed(msgHdrsInFolder[8]);
-
- // finally restore all tabs
- _synthesizeRecentlyClosedMenu();
-
- assert_true(menu.itemCount == 10, "Failed to populate context menu");
- assert_true(
- tabTitles[1] == menu.getItemAtIndex(0).label,
- "Tab Title does not match Menu item"
- );
- assert_true(
- tabTitles[7] == menu.getItemAtIndex(5).label,
- "Tab Title does not match Menu item"
- );
-
- EventUtils.synthesizeMouse(
- menu.getItemAtIndex(menu.itemCount - 1),
- 5,
- 5,
- {},
- mc.window
- );
- _teardownRecentlyClosedMenu();
-
- wait_for_message_display_completion(mc);
-
- // out of the 16 tab, we closed all except two. As the history can store
- // only 10 items we have to endup with exactly 10 + 2 tabs.
- assert_number_of_tabs_open(12);
-}
-
-function teardownTest(test) {
- switch (test) {
- case test_tab_reorder_detach:
- case test_tab_reorder_window:
- // Some test cases open new windows, thus we need to ensure all
- // opened windows get closed.
-
- let en = Services.wm.getEnumerator("mail:3pane");
-
- while (en.hasMoreElements()) {
- var win = en.getNext();
-
- if (win != mc.window) {
- close_window(new mozmill.controller.MozMillController(win));
- }
- }
-
- // fall through!
-
- case test_tab_reorder_tabbar:
- case test_tab_recentlyClosed:
- case test_tab_undo:
- // clean up the tabbbar
- mc.tabmail.closeOtherTabs(0);
- assert_number_of_tabs_open(1);
- }
-}
deleted file mode 100644
--- a/mail/test/mozmill/utils/html/collections.html
+++ /dev/null
@@ -1,26 +0,0 @@
-<html>
- <head>
- <title>Collections</title>
- <script>
- const JS_HAS_SYMBOLS = typeof Symbol === "function";
- const ITERATOR_SYMBOL = JS_HAS_SYMBOLS ? Symbol.iterator : "@@iterator";
- var gIterator = (function* () {
- yield 1; yield 2; yield 3; yield 4; yield 5;
- })();
-
- var gCustomIterator = {
- _array: [6, 7, 8, 9],
- [ITERATOR_SYMBOL]: function* testIterator() {
- for (var i = 0; i < this._array.length; ++i) {
- yield this._array[i];
- }
- },
- };
- </script>
- </head>
- <body>
- I have two collections defined - gIterator is an iterator, and contains
- [1, 2, 3, 4, 5], and gCustomIterator is an object with an @@iterator
- method that contains [6, 7, 8, 9].
- </body>
-</html>
deleted file mode 100644
--- a/mail/test/mozmill/utils/test-extensionSupport.js
+++ /dev/null
@@ -1,169 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests ExtensionSupport.jsm functions.
- */
-
-var {
- close_address_book_window,
- open_address_book_window,
-} = ChromeUtils.import(
- "resource://testing-common/mozmill/AddressBookHelpers.jsm"
-);
-var { close_compose_window, open_compose_new_mail } = ChromeUtils.import(
- "resource://testing-common/mozmill/ComposeHelpers.jsm"
-);
-var { assert_equals, assert_false, assert_true } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var { ExtensionSupport } = ChromeUtils.import(
- "resource:///modules/ExtensionSupport.jsm"
-);
-
-/**
- * Bug 1450288
- * Test ExtensionSupport.registerWindowListener and ExtensionSupport.unregisterWindowListener.
- */
-function test_windowListeners() {
- // There may be some pre-existing listeners already set up, e.g. mozmill ones.
- let originalListenerCount = ExtensionSupport.registeredWindowListenerCount;
-
- let addonRunCount = [];
- addonRunCount.load = new Map();
- addonRunCount.unload = new Map();
-
- function addonListener(aAddon, aEvent) {
- if (!addonRunCount[aEvent].has(aAddon)) {
- addonRunCount[aEvent].set(aAddon, 0);
- }
- addonRunCount[aEvent].set(aAddon, addonRunCount[aEvent].get(aAddon) + 1);
- }
-
- function addonCount(aAddon, aEvent) {
- if (!addonRunCount[aEvent].has(aAddon)) {
- return 0;
- }
-
- return addonRunCount[aEvent].get(aAddon);
- }
-
- // Extension listening to all windows and all events.
- assert_true(
- ExtensionSupport.registerWindowListener("test-addon1", {
- onLoadWindow() {
- addonListener("test-addon1", "load");
- },
- onUnloadWindow() {
- addonListener("test-addon1", "unload");
- },
- })
- );
-
- assert_equals(addonCount("test-addon1", "load"), 1);
-
- // Extension listening to compose window only.
- assert_true(
- ExtensionSupport.registerWindowListener("test-addon2", {
- chromeURLs: [
- "chrome://messenger/content/messengercompose/messengercompose.xhtml",
- ],
- onLoadWindow() {
- addonListener("test-addon2", "load");
- },
- onUnloadWindow() {
- addonListener("test-addon2", "unload");
- },
- })
- );
-
- let cwc = open_compose_new_mail();
-
- assert_equals(addonCount("test-addon1", "load"), 2);
- assert_equals(addonCount("test-addon2", "load"), 1);
-
- // Extension listening to compose window once while it is already open.
- assert_true(
- ExtensionSupport.registerWindowListener("test-addon3", {
- chromeURLs: [
- "chrome://messenger/content/messengercompose/messengercompose.xhtml",
- ],
- onLoadWindow() {
- addonListener("test-addon3", "load");
- ExtensionSupport.unregisterWindowListener("test-addon3");
- },
- })
- );
-
- assert_equals(addonCount("test-addon3", "load"), 1);
-
- // Extension listening to compose window while it is already open.
- assert_true(
- ExtensionSupport.registerWindowListener("test-addon4", {
- chromeURLs: [
- "chrome://messenger/content/messengercompose/messengercompose.xhtml",
- ],
- onLoadWindow() {
- addonListener("test-addon4", "load");
- },
- onUnloadWindow() {
- addonListener("test-addon4", "unload");
- ExtensionSupport.unregisterWindowListener("test-addon4");
- },
- })
- );
-
- assert_equals(addonCount("test-addon4", "load"), 1);
-
- close_compose_window(cwc);
-
- assert_equals(addonCount("test-addon1", "unload"), 1);
- assert_equals(addonCount("test-addon2", "unload"), 1);
- assert_equals(addonCount("test-addon3", "unload"), 0);
- assert_equals(addonCount("test-addon4", "unload"), 1);
-
- cwc = open_compose_new_mail();
-
- assert_equals(addonCount("test-addon1", "load"), 3);
- // Addon3 didn't listen to the new compose window, addon2 did.
- assert_equals(addonCount("test-addon2", "load"), 2);
- assert_equals(addonCount("test-addon3", "load"), 1);
-
- close_compose_window(cwc);
-
- assert_equals(addonCount("test-addon1", "unload"), 2);
- assert_equals(addonCount("test-addon2", "unload"), 2);
- assert_equals(addonCount("test-addon3", "unload"), 0);
-
- let abc = open_address_book_window();
- // Only Addon1 listens to any window.
- assert_equals(addonCount("test-addon1", "load"), 4);
- assert_equals(addonCount("test-addon2", "load"), 2);
- assert_equals(addonCount("test-addon3", "load"), 1);
- assert_equals(addonCount("test-addon4", "load"), 1);
-
- close_address_book_window(abc);
-
- assert_equals(addonCount("test-addon1", "unload"), 3);
- assert_equals(addonCount("test-addon2", "unload"), 2);
- assert_equals(addonCount("test-addon3", "unload"), 0);
- assert_equals(addonCount("test-addon4", "unload"), 1);
-
- // Registering with some invalid data should fail.
- assert_false(ExtensionSupport.registerWindowListener("", {}));
- assert_false(ExtensionSupport.registerWindowListener("test-addon1", {}));
- assert_false(ExtensionSupport.registerWindowListener("test-addon5", {}));
- assert_false(ExtensionSupport.unregisterWindowListener(""));
- assert_false(ExtensionSupport.unregisterWindowListener("test-addon5"));
-
- // Clean up addon registrations. addon3 unregistered itself already.
- assert_true(ExtensionSupport.unregisterWindowListener("test-addon1"));
- assert_true(ExtensionSupport.unregisterWindowListener("test-addon2"));
- assert_false(ExtensionSupport.unregisterWindowListener("test-addon3"));
- assert_equals(
- ExtensionSupport.registeredWindowListenerCount,
- originalListenerCount
- );
-}
deleted file mode 100644
--- a/mail/test/mozmill/utils/test-iteratorUtils.js
+++ /dev/null
@@ -1,80 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Tests iteratorUtils with items pulled from content into chrome.
- */
-
-var { open_content_tab_with_url } = ChromeUtils.import(
- "resource://testing-common/mozmill/ContentTabHelpers.jsm"
-);
-var { assert_equals, close_tab } = ChromeUtils.import(
- "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
-);
-
-var iteratorUtils = ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var kWhatsNewPref = "mailnews.start_page.override_url";
-
-var gUrl = collector.addHttpResource("../utils/html", "");
-var gCollectionsUrl = gUrl + "collections.html";
-var gOriginalWhatsNew, gTab;
-
-function setupModule(module) {
- gOriginalWhatsNew = Services.prefs.getCharPref(kWhatsNewPref);
- Services.prefs.setCharPref(kWhatsNewPref, gCollectionsUrl);
-}
-
-function teardownModule(module) {
- Services.prefs.setCharPref(kWhatsNewPref, gOriginalWhatsNew);
-}
-
-function setupTest() {
- gTab = open_content_tab_with_url(gCollectionsUrl);
-}
-
-function teardownTest() {
- close_tab(gTab);
-}
-
-/**
- * Tests that we can use iteratorUtils.toArray on an Iterator created
- * and pulled in from content.
- */
-function test_toArray_builtin_content_iterator() {
- // kExpected matches our expectations for the contents of gIterator
- // defined collections.html.
- const kExpected = [1, 2, 3, 4, 5];
-
- // Yank the iterator out from content
- let iter = gTab.browser.contentWindow.wrappedJSObject.gIterator;
- let iterArray = iteratorUtils.toArray(iter);
-
- assert_equals(kExpected.length, iterArray.length);
-
- kExpected.forEach((val, i) => {
- assert_equals(val, iterArray[i]);
- });
-}
-
-/**
- * Tests that we can use iteratorUtils.toArray on a custom iterator created
- * and pulled in from content.
- */
-function test_toArray_custom_content_iterator() {
- // kExpected matches our expectations for the contents of gCustomIterator
- // defined in collections.html.
- const kExpected = [6, 7, 8, 9];
-
- // Yank the iterator out from content
- let iter = gTab.browser.contentWindow.wrappedJSObject.gCustomIterator;
- let iterArray = iteratorUtils.toArray(iter);
-
- assert_equals(kExpected.length, iterArray.length);
-
- for (let [i, val] of kExpected.entries()) {
- assert_equals(val, iterArray[i]);
- }
-}
deleted file mode 100644
--- a/mail/test/resources/installmozmill.py
+++ /dev/null
@@ -1,105 +0,0 @@
-#!/usr/bin/env python
-
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-"""
-install mozmill and its dependencies
-"""
-
-import os
-import sys
-from subprocess import call
-
-import buildconfig
-
-# utility functions for cross-platform
-
-
-def is_windows():
- return sys.platform.startswith('win')
-
-
-def esc(path):
- """quote and escape a path for cross-platform use"""
- return '"%s"' % repr(path)[1:-1]
-
-
-def scripts_path(virtual_env):
- """path to scripts directory"""
- if is_windows():
- return os.path.join(virtual_env, 'Scripts')
- return os.path.join(virtual_env, 'bin')
-
-
-def python_script_path(virtual_env, script_name):
- """path to a python script in a virtualenv"""
- scripts_dir = scripts_path(virtual_env)
- if is_windows():
- script_name = script_name + '-script.py'
- return os.path.join(scripts_dir, script_name)
-
-
-def entry_point_path(virtual_env, entry_point):
- path = os.path.join(scripts_path(virtual_env), entry_point)
- if is_windows():
- path += '.exe'
- return path
-
-
-# command-line entry point
-def main(args=None):
- """command line front-end function"""
-
- # parse command line arguments
- args = args or sys.argv[1:]
-
- # Print the python version
- print('Python: %s' % sys.version)
-
- # The data is kept in the same directory as the script
- source = os.path.abspath(os.path.dirname(__file__))
-
- # directory to install to
- if len(args) == 1:
- destination = os.path.abspath(args[0])
- else:
- print("Usage: %s destination" % sys.argv[0])
- sys.exit(1)
-
- topsrcdir = buildconfig.substs['top_srcdir']
-
- mozbase = os.path.join(topsrcdir, "testing/mozbase")
- mozpython = os.path.join(topsrcdir, "python")
-
- os.chdir(source)
-
- # packages to install in dependency order
- packages = ["jsbridge", "mozmill"]
-
- # create the virtualenv and install packages
- env = os.environ.copy()
- env.pop('PYTHONHOME', None)
- pip = entry_point_path(destination, 'pip')
-
- # Install packages to the virtualenv
- mozbase_packages = [
- 'manifestparser', 'mozfile', 'mozinfo', 'mozlog', 'mozprofile',
- 'mozcrash', 'moznetwork', 'mozprocess', 'mozdevice', 'mozrunner',
- ]
- python_packages = ['mozterm']
-
- returncode = call(
- [pip, 'install'] +
- [os.path.join(mozbase, package) for package in mozbase_packages] +
- [os.path.join(mozpython, package) for package in python_packages] +
- [os.path.abspath(package) for package in packages],
- env=env)
- if returncode:
- print('Failure to install packages')
- sys.exit(returncode)
-
-
-if __name__ == '__main__':
- main()
deleted file mode 100644
--- a/mail/test/resources/jsbridge/MANIFEST.in
+++ /dev/null
@@ -1,2 +0,0 @@
-recursive-include jsbridge/extension *
-recursive-include jsbridge/xpi *
deleted file mode 100644
--- a/mail/test/resources/jsbridge/jsbridge/__init__.py
+++ /dev/null
@@ -1,184 +0,0 @@
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is Mozilla Corporation Code.
-#
-# The Initial Developer of the Original Code is
-# Mikeal Rogers.
-# Portions created by the Initial Developer are Copyright (C) 2008 -2009
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mikeal Rogers <mikeal.rogers@gmail.com>
-# Henrik Skupin <hskupin@mozilla.com>
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 2 or later (the "GPL"), or
-# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-import socket
-import os
-import asyncore
-
-from time import sleep
-from network import create_network
-from jsobjects import JSObject
-
-import mozrunner
-
-settings_env = 'JSBRIDGE_SETTINGS_FILE'
-
-parent = os.path.abspath(os.path.dirname(__file__))
-extension_path = os.path.join(parent, 'extension')
-
-window_string = "Cc['@mozilla.org/appshell/window-mediator;1'].getService(Ci.nsIWindowMediator).getMostRecentWindow('')"
-
-wait_to_create_timeout = 90
-
-
-def wait_and_create_network(host, port, timeout=wait_to_create_timeout):
- ttl = 0
- while ttl < timeout:
- try:
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- s.connect((host, port))
- s.close()
- break
- except socket.error:
- pass
- sleep(.25)
- ttl += .25
- if ttl == timeout:
- raise Exception("Sorry, cannot connect to jsbridge extension, port %s" % port)
-
- back_channel, bridge = create_network(host, port)
- sleep(.5)
-
- while back_channel.registered is False:
- back_channel.close()
- bridge.close()
- asyncore.socket_map = {}
- sleep(1)
- back_channel, bridge = create_network(host, port)
-
- return back_channel, bridge
-
-
-class CLI(mozrunner.CLI):
- """Command line interface."""
-
- module = "jsbridge"
-
- def add_options(self, parser):
- """add options to parser"""
-
- mozrunner.CLI.add_options(self, parser)
- parser.add_option('-D', '--debug', dest="debug",
- action="store_true",
- help="Debug mode",
- metavar="JSBRIDGE_DEBUG",
- default=False)
- parser.add_option('-s', '--shell', dest="shell",
- action="store_true",
- help="Start a Python shell",
- metavar="JSBRIDGE_SHELL",
- default=False)
- parser.add_option('-u', '--usecode', dest="usecode",
- action="store_true",
- help="Use code module instead of iPython",
- default=False)
- parser.add_option('-P', '--port', dest="port", default="24242",
- help="TCP port to run jsbridge on.")
-
- def profile_args(self):
- profargs = super(CLI, self).profile_args()
- # Bug 1103551: re-enable these preferences.
- # if self.options.debug:
- # profargs.setdefault('prefences', []).update({
- # 'extensions.checkCompatibility':False,
- # 'devtools.errorconsole.enabled':True,
- # 'javascript.options.strict': True
- # })
- profargs.setdefault('addons', []).append(extension_path)
- return profargs
-
- def command_args(self):
- args = super(CLI, self).command_args()
- if self.options.debug:
- args.append('-jsconsole')
- if 'jsbridge' not in args:
- args += ['-jsbridge', self.options.port]
- return args
-
- def run(self):
- runner = self.create_runner()
- runner.start()
- self.start_jsbridge_network()
- if self.options.shell:
- self.start_shell(runner)
- else:
- try:
- runner.wait()
- except KeyboardInterrupt:
- runner.stop()
-
- runner.profile.cleanup()
-
- def start_shell(self, runner):
- try:
- import IPython
- except:
- IPython = None
- if not hasattr(self, 'bridge'):
- self.start_jsbridge_network()
- jsobj = JSObject(self.bridge, window_string)
-
- if IPython is None or self.options.usecode:
- import code
- code.interact(local={
- "jsobj": jsobj,
- "getBrowserWindow": lambda: getBrowserWindow(self.bridge),
- "back_channel": self.back_channel,
- })
- else:
- from IPython.Shell import IPShellEmbed
- ipshell = IPShellEmbed([])
- ipshell(local_ns={
- "jsobj": jsobj,
- "getBrowserWindow": lambda: getBrowserWindow(self.bridge),
- "back_channel": self.back_channel,
- })
- runner.stop()
-
- def start_jsbridge_network(self, timeout=10):
- port = int(self.options.port)
- host = '127.0.0.1'
- self.back_channel, self.bridge = wait_and_create_network(host, port, timeout)
-
-
-def cli():
- CLI().run()
-
-
-def getBrowserWindow(bridge):
- return JSObject(bridge, "Cc['@mozilla.org/appshell/window-mediator;1'].getService(Ci.nsIWindowMediator).getMostRecentWindow('')")
deleted file mode 100644
--- a/mail/test/resources/jsbridge/jsbridge/extension/bootstrap.js
+++ /dev/null
@@ -1,50 +0,0 @@
-/* -*- Mode: JavaScript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var { ExtensionSupport } = ChromeUtils.import(
- "resource:///modules/ExtensionSupport.jsm"
-);
-
-var addonID;
-
-function install() {}
-
-function uninstall() {}
-
-function startup(data, reason) {
- addonID = data.id;
- ExtensionSupport.registerWindowListener(addonID, {
- chromeURLs: ["chrome://messenger/content/messenger.xhtml"],
- onLoadWindow: setupServer,
- });
-}
-
-function shutdown(data, reason) {
- // This should have already been unregistered in setupServer().
- // We do it again, just in case something went wrong.
- ExtensionSupport.unregisterWindowListener(data.id);
-}
-
-function setupServer(domWindow) {
- Services.scriptloader.loadSubScript(
- "chrome://jsbridge/content/overlay.js",
- domWindow
- );
-
- let server = {};
- ChromeUtils.import("chrome://jsbridge/content/modules/server.js", server);
- console.log("=== JS Bridge: Starting server");
- server.startServer(24242);
-
- // We only needed to start the server once, so unregister the listener.
- ExtensionSupport.unregisterWindowListener(addonID);
-}
-
-function logException(exc) {
- try {
- Services.console.logStringMessage(exc.toString() + "\n" + exc.stack);
- } catch (x) {}
-}
deleted file mode 100644
--- a/mail/test/resources/jsbridge/jsbridge/extension/chrome.manifest
+++ /dev/null
@@ -1,1 +0,0 @@
-content jsbridge chrome/content/
deleted file mode 100644
--- a/mail/test/resources/jsbridge/jsbridge/extension/chrome/content/modules/events.js
+++ /dev/null
@@ -1,16 +0,0 @@
-var EXPORTED_SYMBOLS = ["backchannels", "fireEvent", "addBackChannel"];
-
-var backchannels = [];
-
-function fireEvent(name, obj) {
- for (let backchannel of backchannels) {
- backchannel.session.encodeOut({
- eventType: name,
- result: obj,
- });
- }
-}
-
-function addBackChannel(backchannel) {
- backchannels.push(backchannel);
-}
deleted file mode 100644
--- a/mail/test/resources/jsbridge/jsbridge/extension/chrome/content/modules/init.js
+++ /dev/null
@@ -1,40 +0,0 @@
-// ***** BEGIN LICENSE BLOCK *****
-// Version: MPL 1.1/GPL 2.0/LGPL 2.1
-//
-// The contents of this file are subject to the Mozilla Public License Version
-// 1.1 (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
-// http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an "AS IS" basis,
-// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-// for the specific language governing rights and limitations under the
-// License.
-//
-// The Original Code is Mozilla Corporation Code.
-//
-// The Initial Developer of the Original Code is
-// Mikeal Rogers.
-// Portions created by the Initial Developer are Copyright (C) 2008
-// the Initial Developer. All Rights Reserved.
-//
-// Contributor(s):
-// Mikeal Rogers <mikeal.rogers@gmail.com>
-//
-// Alternatively, the contents of this file may be used under the terms of
-// either the GNU General Public License Version 2 or later (the "GPL"), or
-// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-// in which case the provisions of the GPL or the LGPL are applicable instead
-// of those above. If you wish to allow use of your version of this file only
-// under the terms of either the GPL or the LGPL, and not to allow others to
-// use your version of this file under the terms of the MPL, indicate your
-// decision by deleting the provisions above and replace them with the notice
-// and other provisions required by the GPL or the LGPL. If you do not delete
-// the provisions above, a recipient may use your version of this file under
-// the terms of any one of the MPL, the GPL or the LGPL.
-//
-// ***** END LICENSE BLOCK *****
-
-var EXPORTED_SYMBOLS = ["server"];
-
-var server = ChromeUtils.import("chrome://jsbridge/content/modules/server.js");
deleted file mode 100644
--- a/mail/test/resources/jsbridge/jsbridge/extension/chrome/content/modules/server.js
+++ /dev/null
@@ -1,421 +0,0 @@
-// ***** BEGIN LICENSE BLOCK *****
-// Version: MPL 1.1/GPL 2.0/LGPL 2.1
-//
-// The contents of this file are subject to the Mozilla Public License Version
-// 1.1 (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
-// http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an "AS IS" basis,
-// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-// for the specific language governing rights and limitations under the
-// License.
-//
-// The Original Code is Mozilla Corporation Code.
-//
-// The Initial Developer of the Original Code is
-// based on the MozRepl project.
-// Portions created by the Initial Developer are Copyright (C) 2008
-// the Initial Developer. All Rights Reserved.
-//
-// Contributor(s):
-// Mikeal Rogers <mikeal.rogers@gmail.com>
-// Massimiliano Mirra <bard@hyperstruct.net>
-//
-// Alternatively, the contents of this file may be used under the terms of
-// either the GNU General Public License Version 2 or later (the "GPL"), or
-// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-// in which case the provisions of the GPL or the LGPL are applicable instead
-// of those above. If you wish to allow use of your version of this file only
-// under the terms of either the GPL or the LGPL, and not to allow others to
-// use your version of this file under the terms of the MPL, indicate your
-// decision by deleting the provisions above and replace them with the notice
-// and other provisions required by the GPL or the LGPL. If you do not delete
-// the provisions above, a recipient may use your version of this file under
-// the terms of any one of the MPL, the GPL or the LGPL.
-//
-// ***** END LICENSE BLOCK *****
-
-var EXPORTED_SYMBOLS = [
- "Server",
- "server",
- "AsyncRead",
- "Session",
- "sessions",
- "globalRegistry",
- "startServer",
-];
-
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var events = ChromeUtils.import("chrome://jsbridge/content/modules/events.js");
-var DEBUG_ON = false;
-var BUFFER_SIZE = 1024;
-
-var uuidgen = Cc["@mozilla.org/uuid-generator;1"].getService(
- Ci.nsIUUIDGenerator
-);
-
-function AsyncRead(session) {
- this.session = session;
-}
-
-AsyncRead.prototype.onStartRequest = function(request) {};
-AsyncRead.prototype.onStopRequest = function(request, status) {
- log("async onstoprequest: onstoprequest");
- this.session.onQuit();
-};
-AsyncRead.prototype.onDataAvailable = function(
- request,
- inputStream,
- offset,
- count
-) {
- var str = {};
- str.value = "";
-
- var bytesAvail = 0;
- do {
- var parts = {};
- if (count > BUFFER_SIZE) {
- bytesAvail = BUFFER_SIZE;
- } else {
- bytesAvail = count;
- }
-
- log("jsbridge: onDataAvailable, reading bytesAvail = " + bytesAvail + "\n");
- var bytesRead = this.session.instream.readString(bytesAvail, parts);
- count = count - bytesRead;
- log(
- "jsbridge: onDataAvailable, read bytes: " +
- bytesRead +
- " count is now: " +
- count +
- "\n"
- );
- str.value += parts.value;
- } while (count > 0);
- log(
- "jsbridge: onDataAvailable, going into receive with: \n\n" +
- str.value +
- "\n\n"
- );
- this.session.receive(str.value);
-};
-
-var globalRegistry = {};
-
-function Bridge(session) {
- this.session = session;
- this.registry = globalRegistry;
-}
-Bridge.prototype._register = function(_type) {
- this.bridgeType = _type;
- if (_type == "backchannel") {
- events.addBackChannel(this);
- }
-};
-Bridge.prototype.register = function(uuid, _type) {
- try {
- this._register(_type);
- var passed = true;
- } catch (e) {
- var exception;
- if (typeof e == "string") {
- exception = e;
- } else {
- exception = {
- name: e.name,
- message: e.message,
- };
- }
- this.session.encodeOut({
- result: false,
- exception,
- uuid,
- });
- }
- if (passed != undefined) {
- this.session.encodeOut({
- result: true,
- eventType: "register",
- uuid,
- });
- }
-};
-Bridge.prototype._describe = function(obj) {
- var response = {};
- var type;
- if (obj === null) {
- type = "null";
- } else {
- type = typeof obj;
- }
- if (type == "object") {
- if (obj.length != undefined) {
- type = "array";
- }
- response.attributes = [];
- for (var i in obj) {
- response.attributes = response.attributes.concat(i);
- }
- } else if (type != "function") {
- response.data = obj;
- }
- response.type = type;
- return response;
-};
-Bridge.prototype.describe = function(uuid, obj) {
- var response = this._describe(obj);
- response.uuid = uuid;
- response.result = true;
- this.session.encodeOut(response);
-};
-Bridge.prototype._set = function(obj) {
- var uuid = uuidgen.generateUUID().toString();
- this.registry[uuid] = obj;
- return uuid;
-};
-Bridge.prototype.set = function(uuid, obj) {
- var ruuid = this._set(obj);
- this.session.encodeOut({
- result: true,
- data: `bridge.registry["${ruuid}"]`,
- uuid,
- });
-};
-Bridge.prototype._setAttribute = function(obj, name, value) {
- obj[name] = value;
- return value;
-};
-Bridge.prototype.setAttribute = function(uuid, obj, name, value) {
- try {
- var result = this._setAttribute(obj, name, value);
- } catch (e) {
- var exception;
- if (typeof e == "string") {
- exception = e;
- } else {
- exception = {
- name: e.name,
- message: e.message,
- };
- }
- this.session.encodeOut({
- result: false,
- exception,
- uuid,
- });
- }
- if (result != undefined) {
- this.set(uuid, obj[name]);
- }
-};
-Bridge.prototype._execFunction = function(func, args) {
- return func.apply(this.session.sandbox, args);
-};
-Bridge.prototype.execFunction = function(uuid, func, args) {
- var result;
- try {
- var data = this._execFunction(func, args);
- result = true;
- } catch (e) {
- var exception;
- if (typeof e == "string") {
- exception = e;
- } else {
- exception = {
- name: e.name,
- message: e.message,
- };
- }
- this.session.encodeOut({
- result: false,
- exception,
- uuid,
- });
- result = true;
- }
- if (data != undefined) {
- this.set(uuid, data);
- } else if (result) {
- this.session.encodeOut({
- result: true,
- data: null,
- uuid,
- });
- } else {
- log("jsbridge threw unknown data in execFunc");
- throw new Error("JSBridge unknown data in execFunc");
- }
-};
-
-var backstage = this;
-
-function Session(transport) {
- this.transpart = transport; // XXX Unused, needed to hold reference? Note the typo.
- let systemPrincipal = Cc["@mozilla.org/systemprincipal;1"].createInstance(
- Ci.nsIPrincipal
- );
- this.sandbox = Cu.Sandbox(systemPrincipal, {
- wantGlobalProperties: ["ChromeUtils"],
- });
- this.sandbox.bridge = new Bridge(this);
- try {
- this.outputstream = transport.openOutputStream(
- Ci.nsITransport.OPEN_BLOCKING,
- 0,
- 0
- );
- this.outstream = Cc[
- "@mozilla.org/intl/converter-output-stream;1"
- ].createInstance(Ci.nsIConverterOutputStream);
- this.outstream.init(this.outputstream, "UTF-8");
- this.stream = transport.openInputStream(0, 0, 0);
- this.instream = Cc[
- "@mozilla.org/intl/converter-input-stream;1"
- ].createInstance(Ci.nsIConverterInputStream);
- this.instream.init(
- this.stream,
- "UTF-8",
- BUFFER_SIZE,
- Ci.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER
- );
- } catch (e) {
- log("jsbridge: Error: " + e);
- }
- log("jsbridge: Accepted connection.");
-
- this.pump = Cc["@mozilla.org/network/input-stream-pump;1"].createInstance(
- Ci.nsIInputStreamPump
- );
- this.pump.init(this.stream, 0, 0, false);
- this.pump.asyncRead(new AsyncRead(this), null);
-}
-Session.prototype.onOutput = function(string) {
- log("jsbridge: write: " + string);
- if (typeof string != "string") {
- throw new Error("This is not a string");
- }
- try {
- var stroffset = 0;
- do {
- var parts = "";
- // Handle the case where we are writing something larger than our buffer
- if (string.length > BUFFER_SIZE) {
- log(
- "jsbridge: onOutput: writing data stroffset is: " +
- stroffset +
- " string.length is: " +
- string.length
- );
- parts = string.slice(stroffset, stroffset + BUFFER_SIZE);
- log("jsbridge: onOutput: here is our part: \n" + parts + "\n");
- } else {
- parts = string;
- }
-
- // Update our offset
- stroffset = stroffset += parts.length;
-
- // write it
- this.outstream.writeString(parts);
- } while (stroffset < string.length);
-
- // Ensure the entire stream is flushed
- this.outstream.flush();
- } catch (e) {
- log("jsbridge: threw on writing string: " + string + " exception: " + e);
- throw new Error("JSBridge cannot write: " + string);
- }
-};
-Session.prototype.onQuit = function() {
- this.instream.close();
- this.outstream.close();
- sessions.remove(this);
-};
-Session.prototype.encodeOut = function(obj) {
- try {
- this.onOutput(JSON.stringify(obj));
- } catch (e) {
- var exception;
- if (typeof e == "string") {
- exception = e;
- } else {
- exception = {
- name: e.name,
- message: e.message,
- };
- }
- this.onOutput(
- JSON.stringify({
- result: false,
- exception,
- })
- );
- }
-};
-Session.prototype.receive = function(data) {
- Cu.evalInSandbox(data, this.sandbox);
-};
-
-var sessions = {
- _list: [],
- add(session) {
- this._list.push(session);
- },
- remove(session) {
- var index = this._list.indexOf(session);
- if (index != -1) {
- this._list.splice(index, 1);
- }
- },
- get(index) {
- return this._list[index];
- },
- quit() {
- this._list.forEach(function(session) {
- session.onQuit();
- });
- this._list.splice(0, this._list.length);
- },
-};
-
-function Server(port) {
- this.port = port;
-}
-Server.prototype.start = function() {
- try {
- this.serv = Cc["@mozilla.org/network/server-socket;1"].createInstance(
- Ci.nsIServerSocket
- );
- this.serv.init(this.port, true, -1);
- this.serv.asyncListen(this);
- } catch (e) {
- log("jsbridge: Exception: " + e);
- }
-};
-Server.prototype.stop = function() {
- log("jsbridge: Closing...");
- this.serv.close();
- this.sessions.quit();
- this.serv = undefined;
-};
-Server.prototype.onStopListening = function(serv, status) {
- // Stub function
-};
-Server.prototype.onSocketAccepted = function(serv, transport) {
- let session = new Session(transport);
- sessions.add(session);
-};
-
-function log(msg) {
- if (DEBUG_ON) {
- dump(msg + "\n");
- }
-}
-
-function startServer(port) {
- var server = new Server(port);
- server.start();
-}
deleted file mode 100644
--- a/mail/test/resources/jsbridge/jsbridge/extension/chrome/content/overlay.js
+++ /dev/null
@@ -1,40 +0,0 @@
-// ***** BEGIN LICENSE BLOCK *****
-// Version: MPL 1.1/GPL 2.0/LGPL 2.1
-//
-// The contents of this file are subject to the Mozilla Public License Version
-// 1.1 (the "License"); you may not use this file except in compliance with
-// the License. You may obtain a copy of the License at
-// http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an "AS IS" basis,
-// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-// for the specific language governing rights and limitations under the
-// License.
-//
-// The Original Code is Mozilla Corporation Code.
-//
-// The Initial Developer of the Original Code is
-// Mikeal Rogers.
-// Portions created by the Initial Developer are Copyright (C) 2008
-// the Initial Developer. All Rights Reserved.
-//
-// Contributor(s):
-// Mikeal Rogers <mikeal.rogers@gmail.com>
-//
-// Alternatively, the contents of this file may be used under the terms of
-// either the GNU General Public License Version 2 or later (the "GPL"), or
-// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-// in which case the provisions of the GPL or the LGPL are applicable instead
-// of those above. If you wish to allow use of your version of this file only
-// under the terms of either the GPL or the LGPL, and not to allow others to
-// use your version of this file under the terms of the MPL, indicate your
-// decision by deleting the provisions above and replace them with the notice
-// and other provisions required by the GPL or the LGPL. If you do not delete
-// the provisions above, a recipient may use your version of this file under
-// the terms of any one of the MPL, the GPL or the LGPL.
-//
-// ***** END LICENSE BLOCK *****
-
-var jsbridgeInit = ChromeUtils.import(
- "chrome://jsbridge/content/modules/init.js"
-);
deleted file mode 100644
--- a/mail/test/resources/jsbridge/jsbridge/extension/manifest.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "manifest_version": 2,
- "name": "jsbridge",
- "version": "2.5.2",
- "applications": {
- "gecko": {
- "id": "jsbridge@mozilla.com"
- }
- },
- "legacy": {
- "type": "bootstrap"
- }
-}
deleted file mode 100644
--- a/mail/test/resources/jsbridge/jsbridge/jsobjects.py
+++ /dev/null
@@ -1,178 +0,0 @@
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is Mozilla Corporation Code.
-#
-# The Initial Developer of the Original Code is
-# Mikeal Rogers.
-# Portions created by the Initial Developer are Copyright (C) 2008
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mikeal Rogers <mikeal.rogers@gmail.com>
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 2 or later (the "GPL"), or
-# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-
-def init_jsobject(cls, bridge, name, value, description=None):
- """Initialize a js object that is a subclassed base type; int, str, unicode, float."""
- obj = cls(value)
- obj._bridge_ = bridge
- obj._name_ = name
- obj._description_ = description
- return obj
-
-
-def create_jsobject(bridge, fullname, value=None, obj_type=None, override_set=False):
- """Create a single JSObject for named object on other side of the bridge.
-
- Handles various initization cases for different JSObjects."""
- description = bridge.describe(fullname)
- obj_type = description['type']
- value = description.get('data', None)
-
- if value is True or value is False:
- return value
-
- if js_type_cases.has_key(obj_type):
- cls, needs_init = js_type_cases[obj_type]
- # Objects that requires initialization are base types that have "values".
- if needs_init:
- obj = init_jsobject(cls, bridge, fullname, value, description=description)
- else:
- obj = cls(bridge, fullname, description=description, override_set=override_set)
- return obj
- else:
- # Something very bad happened, we don't have a representation for the given type.
- raise TypeError("Don't have a JSObject for javascript type " + obj_type)
-
-
-class JSObject(object):
- """Base javascript object representation."""
- _loaded_ = False
-
- def __init__(self, bridge, name, override_set=False, description=None, *args, **kwargs):
- self._bridge_ = bridge
- if not override_set:
- name = bridge.set(name)['data']
- self._name_ = name
- self._description_ = description
-
- def __jsget__(self, name):
- """Abstraction for final step in get events; __getitem__ and __getattr__.
- """
- result = create_jsobject(self._bridge_, name, override_set=True)
- return result
-
- def __getattr__(self, name):
- """Get the object from jsbridge.
-
- Handles lazy loading of all attributes of self."""
- # A little hack so that ipython returns all the names.
- if name == '_getAttributeNames':
- return lambda: self._bridge_.describe(self._name_)['attributes']
-
- attributes = self._bridge_.describe(self._name_)['attributes']
- if name in attributes:
- return self.__jsget__(self._name_ + '["' + name + '"]')
- else:
- raise AttributeError(name + " is undefined.")
-
- __getitem__ = __getattr__
-
- def __setattr__(self, name, value):
- """Set the given JSObject as an attribute of this JSObject and make proper javascript
- assignment on the other side of the bridge."""
- if name.startswith('_') and name.endswith('_'):
- return object.__setattr__(self, name, value)
-
- response = self._bridge_.setAttribute(self._name_, name, value)
- object.__setattr__(self, name, create_jsobject(self._bridge_, response['data'], override_set=True))
-
- __setitem__ = __setattr__
-
-
-class JSFunction(JSObject):
- """Javascript function representation.
-
- Returns a JSObject instance for the serialized js type with
- name set to the full javascript call for this function.
- """
-
- def __init__(self, bridge, name, override_set=False, description=None, *args, **kwargs):
- self._bridge_ = bridge
- self._name_ = name
- self._description_ = description
-
- def __call__(self, *args):
- response = self._bridge_.execFunction(self._name_, args)
- if response['data'] is not None:
- return create_jsobject(self._bridge_, response['data'], override_set=True)
-
-
-class JSString(JSObject, unicode):
- "Javascript string representation."
- __init__ = unicode.__init__
-
-
-class JSInt(JSObject, int):
- """Javascript number representation for Python int."""
- __init__ = int.__init__
-
-
-class JSFloat(JSObject, float):
- """Javascript number representation for Python float."""
- __init__ = float.__init__
-
-
-class JSUndefined(JSObject):
- """Javascript undefined representation."""
- def __str__(self):
- return "undefined"
-
- def __cmp__(self, other):
- if isinstance(other, JSUndefined):
- return True
- else:
- return False
-
- def __nonzero__(self):
- return False
-
-js_type_cases = {
- 'function': (JSFunction, False,),
- 'object': (JSObject, False,),
- 'array': (JSObject, False,),
- 'string': (JSString, True,),
- 'number': (JSFloat, True,),
- 'undefined': (JSUndefined, False,),
- 'null': (JSObject, False,),
-}
-py_type_cases = {
- unicode: JSString,
- str: JSString,
- int: JSInt,
- float: JSFloat,
-}
deleted file mode 100644
--- a/mail/test/resources/jsbridge/jsbridge/network.py
+++ /dev/null
@@ -1,312 +0,0 @@
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is Mozilla Corporation Code.
-#
-# The Initial Developer of the Original Code is
-# Mikeal Rogers.
-# Portions created by the Initial Developer are Copyright (C) 2008
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mikeal Rogers <mikeal.rogers@gmail.com>
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 2 or later (the "GPL"), or
-# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-import asyncore
-import socket
-import select
-import logging
-import uuid
-from time import sleep
-from threading import Thread
-
-import json
-from json.encoder import encode_basestring_ascii, encode_basestring
-
-logger = logging.getLogger(__name__)
-
-
-class JavaScriptException(Exception):
- pass
-
-
-class Telnet(asyncore.dispatcher):
- def __init__(self, host, port):
- self.host, self.port = host, port
- asyncore.dispatcher.__init__(self)
- self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
- self.connect((host, port))
- self.buffer = ''
- self.logger = logger
-
- def __del__(self):
- self.close()
-
- def handle_close(self):
- """override method of asyncore.dispatcher"""
- self.close()
-
- def handle_expt(self):
- self.close() # connection failed, shutdown
-
- def writable(self):
- return (len(self.buffer) > 0)
-
- def handle_write(self):
- sent = self.send(self.buffer)
- self.buffer = self.buffer[sent:]
-
- def read_all(self):
- import socket
- data = ''
- while self.connected:
- try:
- data += self.recv(4096)
- except socket.error:
- break
- return data
-
- def handle_read(self):
- self.data = self.read_all()
- self.process_read(self.data)
-
- def read_callback(self, data):
- return None
-
-decoder = json.JSONDecoder()
-
-
-class JSObjectEncoder(json.JSONEncoder):
- """Encoder that supports jsobject references by name."""
-
- def encode(self, o):
- import jsobjects
- if isinstance(o, jsobjects.JSObject):
- return o._name_
- else:
- return json.JSONEncoder.encode(self, o)
-
- def _iterencode(self, o, markers=None):
- import jsobjects
- if isinstance(o, jsobjects.JSObject):
- yield o._name_
- elif isinstance(o, basestring):
- if self.ensure_ascii:
- encoder = encode_basestring_ascii
- else:
- encoder = encode_basestring
- _encoding = self.encoding
- if (_encoding is not None and isinstance(o, str)
- and not (_encoding == 'utf-8')):
- o = o.decode(_encoding)
- yield encoder(o)
- elif o is None:
- yield 'null'
- elif o is True:
- yield 'true'
- elif o is False:
- yield 'false'
- elif isinstance(o, (int, long)):
- yield str(o)
- elif isinstance(o, float):
- yield getattr(json.encoder, 'floatstr', json.encoder._floatstr)(o, self.allow_nan)
- elif isinstance(o, (list, tuple)):
- for chunk in self._iterencode_list(o, markers):
- yield chunk
- elif isinstance(o, dict):
- for chunk in self._iterencode_dict(o, markers):
- yield chunk
- else:
- if markers is not None:
- markerid = id(o)
- if markerid in markers:
- raise ValueError("Circular reference detected")
- markers[markerid] = o
- for chunk in self._iterencode_default(o, markers):
- yield chunk
- if markers is not None:
- del markers[markerid]
-
-encoder = JSObjectEncoder()
-
-
-class JSBridgeDisconnectError(Exception):
- """exception raised when an unexpected disconnect happens"""
-
-
-class Bridge(Telnet):
-
- trashes = []
- reading = False
- sbuffer = ''
- events_list = []
-
- callbacks = {}
-
- bridge_type = "bridge"
-
- registered = False
- timeout_ctr = 0. # global timeout counter
-
- def __init__(self, host, port, timeout=60.):
- """
- - timeout : failsafe timeout for each call to run in seconds
- """
- self.timeout = timeout
- Telnet.__init__(self, host, port)
- sleep(.1)
-
- # XXX we've actually already connected in Telnet
- self.connect((host, port))
-
- def handle_connect(self):
- self.register()
-
- def run(self, _uuid, exec_string, interval=.2, raise_exeption=True):
- exec_string += '\r\n'
- self.send(exec_string)
-
- while _uuid not in self.callbacks.keys():
-
- Bridge.timeout_ctr += interval
- if Bridge.timeout_ctr > self.timeout:
- print 'Timeout: %s' % exec_string
- raise JSBridgeDisconnectError("Connection timed out")
-
- sleep(interval)
- try:
- self.send('')
- except socket.error, e:
- raise JSBridgeDisconnectError("JSBridge Socket Disconnected: %s" % e)
-
- Bridge.timeout_ctr = 0. # reset the counter
-
- callback = self.callbacks.pop(_uuid)
- if callback['result'] is False and raise_exeption is True:
- raise JavaScriptException(callback['exception'])
- return callback
-
- def register(self):
- _uuid = str(uuid.uuid1())
- self.send('bridge.register("' + _uuid + '", "' + self.bridge_type + '")\r\n')
- self.registered = True
-
- def execFunction(self, func_name, args, interval=.25):
- _uuid = str(uuid.uuid1())
- exec_args = [encoder.encode(_uuid), func_name, encoder.encode(args)]
- return self.run(_uuid, 'bridge.execFunction(' + ', '.join(exec_args) + ')', interval)
-
- def setAttribute(self, obj_name, name, value):
- _uuid = str(uuid.uuid1())
- exec_args = [encoder.encode(_uuid), obj_name, encoder.encode(name), encoder.encode(value)]
- return self.run(_uuid, 'bridge.setAttribute(' + ', '.join(exec_args) + ')')
-
- def set(self, obj_name):
- _uuid = str(uuid.uuid1())
- return self.run(_uuid, 'bridge.set(' + ', '.join([encoder.encode(_uuid), obj_name]) + ')')
-
- def describe(self, obj_name):
- _uuid = str(uuid.uuid1())
- return self.run(_uuid, 'bridge.describe(' + ', '.join([encoder.encode(_uuid), obj_name]) + ')')
-
- def fire_callbacks(self, obj):
- self.callbacks[obj['uuid']] = obj
-
- def process_read(self, data):
- """Parse out json objects and fire callbacks."""
- self.sbuffer += data
- self.reading = True
- self.parsing = True
- while self.parsing:
- # Remove erroneous data in front of callback object
- index = self.sbuffer.find('{')
- if index is not -1 and index is not 0:
- self.sbuffer = self.sbuffer[index:]
- # Try to get a json object from the data stream
- try:
- obj, index = decoder.raw_decode(self.sbuffer)
- except Exception:
- self.parsing = False
- # If we got an object fire the callback infra
- if self.parsing:
- self.fire_callbacks(obj)
- self.sbuffer = self.sbuffer[index:]
-
-
-class BackChannel(Bridge):
-
- bridge_type = "backchannel"
-
- def __init__(self, host, port):
- Bridge.__init__(self, host, port)
- self.uuid_listener_index = {}
- self.event_listener_index = {}
- self.global_listeners = []
-
- def fire_callbacks(self, obj):
- """Handle all callback fireing on json objects pulled from the data stream."""
- self.fire_event(**dict([(str(key), value,) for key, value in obj.items()]))
-
- def add_listener(self, callback, uuid=None, eventType=None):
- if uuid is not None:
- self.uuid_listener_index.setdefault(uuid, []).append(callback)
- if eventType is not None:
- self.event_listener_index.setdefault(eventType, []).append(callback)
-
- def add_global_listener(self, callback):
- self.global_listeners.append(callback)
-
- def fire_event(self, eventType=None, uuid=None, result=None, exception=None):
- Bridge.timeout_ctr = 0. # reset the counter
- event = eventType
- if uuid is not None and self.uuid_listener_index.has_key(uuid):
- for callback in self.uuid_listener_index[uuid]:
- callback(result)
- if event is not None and self.event_listener_index.has_key(event):
- for callback in self.event_listener_index[event]:
- callback(result)
- for listener in self.global_listeners:
- listener(eventType, result)
-
-thread = None
-
-
-def create_network(hostname, port):
- back_channel = BackChannel(hostname, port)
- bridge = Bridge(hostname, port)
- global thread
- if not thread or not thread.isAlive():
- def do():
- try:
- asyncore.loop(use_poll=True)
- except select.error:
- pass
-
- thread = Thread(target=do)
- getattr(thread, 'setDaemon', lambda x: None)(True)
- thread.start()
-
- return back_channel, bridge
deleted file mode 100644
--- a/mail/test/resources/jsbridge/setup.py
+++ /dev/null
@@ -1,77 +0,0 @@
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is Mozilla Corporation Code.
-#
-# The Initial Developer of the Original Code is
-# Mikeal Rogers.
-# Portions created by the Initial Developer are Copyright (C) 2008
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mikeal Rogers <mikeal.rogers@gmail.com>
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 2 or later (the "GPL"), or
-# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-from setuptools import setup, find_packages
-
-desc = """Python to JavaScript bridge interface."""
-summ = """A powerful and extensible Python to JavaScript bridge interface."""
-
-PACKAGE_NAME = "jsbridge_thunderbird"
-# You must update the required version in mozmill's setup.py to match this.
-PACKAGE_VERSION = "2.5.2"
-
-requires = ['mozrunner >= 6.0']
-
-setup(name=PACKAGE_NAME,
- version=PACKAGE_VERSION,
- description=desc,
- long_description=summ,
- author='Mikeal Rogers, Mozilla',
- author_email='mikeal.rogers@gmail.com',
- url='http://github.com/mozautomation/mozmill',
- license='http://www.apache.org/licenses/LICENSE-2.0',
- packages=find_packages(exclude=['test']),
- include_package_data=True,
- package_data={
- '': ['*.js', '*.css', '*.html', '*.txt', '*.xpi', '*.rdf', '*.xhtml', '*.jsm', '*.xml' 'extension'],
- },
- zip_safe=False,
- entry_points="""
- [console_scripts]
- jsbridge = jsbridge:cli
- """,
- platforms=['Any'],
- install_requires=requires,
- classifiers=[
- 'Development Status :: 4 - Beta',
- 'Environment :: Console',
- 'Intended Audience :: Developers',
- 'License :: OSI Approved :: Apache Software License',
- 'Operating System :: OS Independent',
- 'Topic :: Software Development :: Libraries :: Python Modules',
- ]
- )
deleted file mode 100644
--- a/mail/test/resources/mozmill/MANIFEST.in
+++ /dev/null
@@ -1,1 +0,0 @@
-recursive-include mozmill/extension *
deleted file mode 100644
--- a/mail/test/resources/mozmill/mozmill/__init__.py
+++ /dev/null
@@ -1,862 +0,0 @@
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is Mozilla Corporation Code.
-#
-# The Initial Developer of the Original Code is
-# Mikeal Rogers.
-# Portions created by the Initial Developer are Copyright (C) 2008
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mikeal Rogers <mikeal.rogers@gmail.com>
-# Henrik Skupin <hskupin@mozilla.com>
-# Clint Talbert <ctalbert@mozilla.com>
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 2 or later (the "GPL"), or
-# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-import imp
-import os
-import socket
-import sys
-import traceback
-import urllib2
-
-from datetime import datetime, timedelta
-import manifestparser
-
-try:
- import json
-except:
- import simplejson as json
-
-# setup logger
-import logging
-
-import jsbridge
-from jsbridge.network import JSBridgeDisconnectError
-import mozprofile
-import mozrunner
-
-from time import sleep
-
-logger = logging.getLogger('mozmill')
-basedir = os.path.abspath(os.path.dirname(__file__))
-
-extension_path = os.path.join(basedir, 'extension')
-
-mozmillModuleJs = "ChromeUtils.import('resource://testing-common/mozmill/mozmill.jsm')"
-
-try:
- import pkg_resources
- version = pkg_resources.get_distribution('mozmill').version
-except:
- # pkg_resources not available
- version = None
-
-
-class LoggerListener(object):
- cases = {
- 'mozmill.pass': lambda string: logger.info('Step Pass: ' + string),
- 'mozmill.fail': lambda string: logger.error('Test Failure: ' + string),
- 'mozmill.skip': lambda string: logger.info('Test Skipped: ' + string)
- }
-
- class default(object):
- def __init__(self, eName):
- self.eName = eName
-
- def __call__(self, string):
- if string:
- logger.debug(self.eName + ' | ' + string)
- else:
- logger.debug(self.eName)
-
- def __call__(self, eName, obj):
- if obj == {}:
- string = ''
- else:
- string = json.dumps(obj)
-
- if eName not in self.cases:
- self.cases[eName] = self.default(eName)
- self.cases[eName](string)
-
-
-class TestsFailedException(Exception):
- """exception to be raised when the tests fail"""
- # XXX unused
-
-
-class MozMill(object):
- """
- MozMill is a one-shot test runner You should use MozMill as follows:
-
- m = MozMill(...)
- m.start(...)
- m.run_tests()
- m.stop()
-
- You should *NOT* vary from this order of execution. If you have need to
- run different sets of tests, create a new instantiation of MozMill
- """
-
- report_type = 'mozmill-test'
-
- def __init__(self,
- runner_class=mozrunner.FirefoxRunner,
- profile_class=mozprofile.FirefoxProfile,
- jsbridge_port=24242,
- jsbridge_timeout=90):
- """
- - runner_class : which mozrunner class to use
- - profile_class : which class to use to generate application profiles
- - jsbridge_port : port jsbridge uses to connect to the application
- - jsbridge_timeout : how long to go without jsbridge communication
- """
-
- self.runner_class = runner_class
- self.profile_class = profile_class
- self.jsbridge_port = jsbridge_port
- self.jsbridge_timeout = jsbridge_timeout
-
- self.passes = []
- self.fails = []
- self.skipped = []
- self.alltests = []
-
- self.persisted = {}
- self.endRunnerCalled = False
- self.shutdownModes = enum('default', 'user_shutdown', 'user_restart')
- self.currentShutdownMode = self.shutdownModes.default
- self.userShutdownEnabled = False
- self.tests = []
-
- # test time
- self.starttime = self.endtime = None
-
- # setup event listeners
- self.global_listeners = []
- self.listeners = []
- self.add_listener(self.persist_listener, eventType="mozmill.persist")
- self.add_listener(self.endTest_listener, eventType='mozmill.endTest')
- self.add_listener(self.endRunner_listener, eventType='mozmill.endRunner')
- self.add_listener(self.startTest_listener, eventType='mozmill.setTest')
- self.add_listener(self.userShutdown_listener, eventType='mozmill.userShutdown')
-
- # disable the crashreporter
- os.environ['MOZ_CRASHREPORTER_NO_REPORT'] = '1'
-
- def add_listener(self, callback, **kwargs):
- self.listeners.append((callback, kwargs,))
-
- def add_global_listener(self, callback):
- self.global_listeners.append(callback)
-
- def persist_listener(self, obj):
- self.persisted = obj
-
- def fire_python_callback(self, method, arg, python_callbacks_module):
- meth = getattr(python_callbacks_module, method)
- try:
- meth(arg)
- except Exception, e:
- self.endTest_listener({
- "name": method,
- "failed": 1,
- "python_exception_type": e.__class__.__name__,
- "python_exception_string": str(e),
- "python_traceback": traceback.format_exc(),
- "filename": python_callbacks_module.__file__
- })
- return False
- self.endTest_listener({
- "name": method,
- "failed": 0,
- "filename": python_callbacks_module.__file__
- })
- return True
-
- def create_network(self):
-
- # get the bridge and the back-channel
- self.back_channel, self.bridge = jsbridge.wait_and_create_network("127.0.0.1",
- self.jsbridge_port)
-
- # set a timeout on jsbridge actions in order to ensure termination
- self.back_channel.timeout = self.bridge.timeout = self.jsbridge_timeout
-
- # Assign listeners to the back channel
- for listener in self.listeners:
- self.back_channel.add_listener(listener[0], **listener[1])
- for global_listener in self.global_listeners:
- self.back_channel.add_global_listener(global_listener)
-
- def start(self, profile=None, runner=None):
-
- if not profile:
- profile = self.profile_class(addons=[jsbridge.extension_path, extension_path])
- self.profile = profile
-
- if not runner:
- runner = self.runner_class(profile=self.profile,
- cmdargs=["-jsbridge", str(self.jsbridge_port)])
-
- self.runner = runner
- self.endRunnerCalled = False
-
- self.runner.start()
- self.create_network()
- self.appinfo = self.get_appinfo(self.bridge)
-
- # set the starttime for the tests
- # XXX assumes run_tests will be called soon after (currently true)
- self.starttime = datetime.utcnow()
-
- def find_tests(self, tests, files=None):
- if files is None:
- files = []
- for test in tests:
-
- # tests have to be absolute paths to be loaded from JS
- test = os.path.abspath(test)
-
- if os.path.isdir(test):
- directory = test
- for f in os.listdir(directory):
- if not f.startswith('test'):
- continue
- path = os.path.join(directory, f)
- if os.path.isdir(path):
- self.find_tests([path], files)
- else:
- if f.endswith('.js') and path not in files:
- files.append(path)
- else:
- files.append(test)
- return files
-
- def run_tests(self, tests, sleeptime=0):
- """
- run test files or directories
- - test : test files or directories to run
- - sleeptime : initial time to sleep [s] (not sure why the default is 4)
- """
-
- tests = self.find_tests(tests)
- self.tests.extend(tests)
-
- frame = jsbridge.JSObject(self.bridge,
- "ChromeUtils.import('resource://testing-common/mozmill/frame.jsm')")
- sleep(sleeptime)
-
- # transfer persisted data
- frame.persisted = self.persisted
-
- # run the test files
- for test in tests:
- frame.runTestFile(test)
-
- # Give a second for any callbacks to finish.
- sleep(1)
-
- def startTest_listener(self, test):
- self.current_test = test
- print "TEST-START | %s | %s" % (test['filename'], test['name'])
-
- def endTest_listener(self, test):
- fname = os.path.split(test['filename'])[1]
- if fname:
- test['name'] = "%s::%s" % (fname, test['name'])
-
- self.alltests.append(test)
- if test.get('skipped', False):
- print "WARNING | %s | (SKIP) %s" % (test['name'], test.get('skipped_reason', ''))
- self.skipped.append(test)
- elif test['failed'] > 0:
- print "TEST-UNEXPECTED-FAIL | %s | %s" % (test['filename'], test['name'])
- self.fails.append(test)
- else:
- print "TEST-PASS | %s | %s" % (test['filename'], test['name'])
- self.passes.append(test)
-
- def endRunner_listener(self, obj):
- self.endRunnerCalled = True
-
- def userShutdown_listener(self, obj):
- if obj in [self.shutdownModes.default, self.shutdownModes.user_restart, self.shutdownModes.user_shutdown]:
- self.currentShutdownMode = obj
- self.userShutdownEnabled = not self.userShutdownEnabled
-
- # Methods for reporting
-
- def printStats(self):
- """print pass/failed/skipped statistics"""
- print "INFO Passed: %d" % len(self.passes)
- print "INFO Failed: %d" % len(self.fails)
- print "INFO Skipped: %d" % len(self.skipped)
-
- def report_disconnect(self):
- test = self.current_test
- test['passes'] = []
- test['fails'] = [{
- 'exception': {
- 'message': 'Disconnect Error: Application unexpectedly closed'
- }
- }]
- test['passed'] = 0
- test['failed'] = 1
- self.alltests.append(test)
- self.fails.append(test)
-
- def get_appinfo(self, bridge):
- """ Collect application specific information """
-
- mozmill = jsbridge.JSObject(bridge, mozmillModuleJs)
- appInfo = mozmill.appInfo
-
- results = {
- 'application_id': str(appInfo.ID),
- 'application_name': str(appInfo.name),
- 'application_version': str(appInfo.version),
- 'application_locale': str(mozmill.locale),
- 'platform_buildid': str(appInfo.platformBuildID),
- 'platform_version': str(appInfo.platformVersion),
- }
-
- return results
-
- def get_platform_information(self):
- """ Retrieves platform information for test reports. Parts of that code
- come from the dirtyharry application:
- http://github.com/harthur/dirtyharry/blob/master/dirtyutils.py """
-
- import platform
- import re
-
- (system, node, release, version, machine, processor) = platform.uname()
- (bits, linkage) = platform.architecture()
- service_pack = ''
-
- if system in ["Microsoft", "Windows"]:
- # There is a Python bug on Windows to determine platform values
- # http://bugs.python.org/issue7860
- if "PROCESSOR_ARCHITEW6432" in os.environ:
- processor = os.environ.get("PROCESSOR_ARCHITEW6432", processor)
- else:
- processor = os.environ.get('PROCESSOR_ARCHITECTURE', processor)
- system = os.environ.get("OS", system).replace('_', ' ')
- service_pack = os.sys.getwindowsversion()[4]
- elif system == "Linux":
- (distro, version, codename) = platform.dist()
- version = distro + " " + version
- if not processor:
- processor = machine
- elif system == "Darwin":
- system = "Mac"
- (release, versioninfo, machine) = platform.mac_ver()
- version = "OS X " + release
-
- if processor in ["i386", "i686"]:
- if bits == "32bit":
- processor = "x86"
- elif bits == "64bit":
- processor = "x86_64"
- elif processor == "AMD64":
- bits = "64bit"
- processor = "x86_64"
- elif processor == "Power Macintosh":
- processor = "ppc"
-
- bits = re.search(r'(\d+)bit', bits).group(1)
-
- platform = {
- 'hostname': node,
- 'system': system,
- 'version': version,
- 'service_pack': service_pack,
- 'processor': processor,
- 'bits': bits
- }
-
- return platform
-
- def get_report(self):
- """get the report results"""
- format = "%Y-%m-%dT%H:%M:%SZ"
-
- assert self.tests, 'no tests have been run!'
- assert self.starttime, 'starttime not set; have you started the tests?'
- if not self.endtime:
- self.endtime = datetime.utcnow()
-
- report = {
- 'report_type': self.report_type,
- 'mozmill_version': version,
- 'time_start': self.starttime.strftime(format),
- 'time_end': self.endtime.strftime(format),
- 'time_upload': 'n/a',
- 'tests_passed': len(self.passes),
- 'tests_failed': len(self.fails),
- 'tests_skipped': len(self.skipped),
- 'results': self.alltests
- }
-
- report.update(self.appinfo)
- report.update(self.runner.get_repositoryInfo())
- report['system_info'] = self.get_platform_information()
-
- return report
-
- def send_report(self, results, report_url):
- """ Send a report of the results to a CouchdB instance or a file. """
-
- # report to file or stdout
- f = None
- if report_url == 'stdout': # stdout
- f = sys.stdout
- if report_url.startswith('file://'):
- filename = report_url.split('file://', 1)[1]
- try:
- f = file(filename, 'w')
- except Exception, e:
- print "Printing results to '%s' failed (%s)." % (filename, e)
- return
- if f:
- print >> f, json.dumps(results)
- return
-
- # report to CouchDB
- try:
- # Set the upload time of the report
- now = datetime.utcnow()
- results['time_upload'] = now.strftime("%Y-%m-%dT%H:%M:%SZ")
-
- # Send a POST request to the DB; the POST is implied by the body data
- body = json.dumps(results)
- request = urllib2.Request(report_url, body, {"Content-Type": "application/json"})
-
- # Get response which contains the id of the new document
- response = urllib2.urlopen(request)
- data = json.loads(response.read())
-
- # Print document location to the console and return
- print "Report document created at '%s%s'" % (report_url, data['id'])
- return data
- except urllib2.HTTPError, e:
- data = json.loads(e.read())
- print "Sending results to '%s' failed (%s)." % (report_url, data['reason'])
- except urllib2.URLError, e:
- print "Sending results to '%s' failed (%s)." % (report_url, e.reason)
-
- def report(self, report_url):
- """print statistics and send the JSON report"""
- self.printStats()
-
- if report_url:
- results = self.get_report()
- return self.send_report(results, report_url)
-
- # Methods for shutting down and cleanup
-
- def stop_runner(self, timeout=30, close_bridge=False, hard=False):
- sleep(1)
- try:
- mozmill = jsbridge.JSObject(self.bridge, mozmillModuleJs)
- mozmill.cleanQuit()
- except (socket.error, JSBridgeDisconnectError):
- pass
- except:
- self.runner.cleanup()
- raise
-
- if not close_bridge:
- starttime = datetime.utcnow()
- self.runner.wait(timeout=timeout)
- endtime = datetime.utcnow()
- if (endtime - starttime) > timedelta(seconds=timeout):
- try:
- self.runner.stop()
- except:
- pass
- self.runner.wait()
- else: # TODO: unify this logic with the above better
- if hard:
- self.runner.cleanup()
- return
-
- # XXX this call won't actually finish in the specified timeout time
- self.runner.wait(timeout=timeout)
-
- self.back_channel.close()
- self.bridge.close()
- x = 0
- while x < timeout:
- if self.endRunnerCalled:
- break
- sleep(1)
- x += 1
- else:
- print "WARNING | endRunner was never called. There must have been a failure in the framework."
- self.runner.cleanup()
- sys.exit(1)
-
- def stop(self, fatal=False):
- """cleanup"""
-
- # stop the runner
- self.stop_runner(timeout=10, close_bridge=True, hard=fatal)
-
- # cleanup the profile if you need to
- if self.runner is not None:
- self.runner.cleanup()
-
-
-class MozMillRestart(MozMill):
-
- report_type = 'mozmill-restart-test'
-
- def __init__(self, *args, **kwargs):
- MozMill.__init__(self, *args, **kwargs)
- self.python_callbacks = []
-
- def add_listener(self, callback, **kwargs):
- self.listeners.append((callback, kwargs,))
-
- def add_global_listener(self, callback):
- self.global_listeners.append(callback)
-
- def start(self, runner=None, profile=None):
-
- if not profile:
- profile = self.profile_class(addons=[jsbridge.extension_path, extension_path])
- self.profile = profile
-
- if not runner:
- runner = self.runner_class(profile=self.profile,
- cmdargs=["-jsbridge", str(self.jsbridge_port)])
- self.runner = runner
- self.endRunnerCalled = False
-
- # set the starttime for the tests
- # XXX assumes run_tests will be called soon after (currently true)
- self.starttime = datetime.utcnow()
-
- def start_runner(self):
-
- # if user_restart we don't need to start the browser back up
- if self.currentShutdownMode != self.shutdownModes.user_restart:
- self.runner.start()
-
- self.create_network()
- self.appinfo = self.get_appinfo(self.bridge)
- frame = jsbridge.JSObject(self.bridge,
- "ChromeUtils.import('resource://testing-common/mozmill/frame.jsm')")
- return frame
-
- def run_dir(self, test_dir, sleeptime=0):
- """run a directory of restart tests resetting the profile per directory"""
-
- # TODO: document this behaviour!
- if os.path.isfile(os.path.join(test_dir, 'testPre.js')):
- pre_test = os.path.join(test_dir, 'testPre.js')
- post_test = os.path.join(test_dir, 'testPost.js')
- if not os.path.exists(pre_test) or not os.path.exists(post_test):
- print "Skipping " + test_dir + " does not contain both pre and post test."
- return
-
- tests = [pre_test, post_test]
- else:
- if not os.path.isfile(os.path.join(test_dir, 'test1.js')):
- print "Skipping " + test_dir + " does not contain any known test file names"
- return
- tests = []
- counter = 1
- while os.path.isfile(os.path.join(test_dir, "test" + str(counter) + ".js")):
- tests.append(os.path.join(test_dir, "test" + str(counter) + ".js"))
- counter += 1
-
- self.add_listener(self.endRunner_listener, eventType='mozmill.endRunner')
-
- if os.path.isfile(os.path.join(test_dir, 'callbacks.py')):
- self.python_callbacks_module = imp.load_source('callbacks', os.path.join(test_dir, 'callbacks.py'))
-
- for test in tests:
- frame = self.start_runner()
- self.currentShutdownMode = self.shutdownModes.default
- self.endRunnerCalled = False
- sleep(sleeptime)
-
- frame.persisted = self.persisted
- try:
- frame.runTestFile(test)
- while not self.endRunnerCalled:
- sleep(.25)
- self.currentShutdownMode = self.shutdownModes.default
- self.stop_runner()
- sleep(2) # Give mozrunner some time to shutdown the browser
- except JSBridgeDisconnectError:
- if not self.userShutdownEnabled:
- raise JSBridgeDisconnectError()
- self.userShutdownEnabled = False
-
- for callback in self.python_callbacks:
- self.fire_python_callback(callback['method'], callback['arg'], self.python_callbacks_module)
- self.python_callbacks = []
-
- self.python_callbacks_module = None
-
- # Reset the profile.
- profile = self.runner.profile
- profile.cleanup()
- if profile.create_new:
- profile.profile = profile.create_new_profile(self.runner.binary)
- for addon in profile.addons:
- profile.install_addon(addon)
- if jsbridge.extension_path not in profile.addons:
- profile.install_addon(jsbridge.extension_path)
- if extension_path not in profile.addons:
- profile.install_addon(extension_path)
- profile.set_preferences(profile.preferences)
-
- def find_tests(self, tests):
- files = []
-
- # make sure these are all directories
- not_dir = [i for i in tests if not os.path.isdir(i)]
- if not_dir:
- raise IOError('Restart tests must be directories (%s)' % ', '.join(not_dir))
-
- for test_dir in tests:
-
- # tests have to be absolute paths, for some reason
- test_dir = os.path.abspath(test_dir)
-
- # XXX this allows for only one sub-level of test directories
- # is this a spec or a side-effect?
- # If the former, it should be documented
- test_dirs = [os.path.join(test_dir, d)
- for d in os.listdir(test_dir)
- if d.startswith('test') and os.path.isdir(os.path.join(test_dir, d))]
-
- if len(test_dirs):
- files.extend(test_dirs)
- else:
- files.append(test_dir)
-
- return files
-
- def run_tests(self, tests, sleeptime=0):
-
- test_dirs = self.find_tests(tests)
- self.tests.extend(test_dirs)
-
- for test_dir in test_dirs:
- self.run_dir(test_dir, sleeptime)
-
- # cleanup the profile
- self.runner.cleanup()
-
- # Give a second for any pending callbacks to finish
- sleep(1)
-
- def stop(self, fatal=False):
- """MozmillRestart doesn't need to do cleanup as this is already done per directory"""
-
- # XXX this is a one-off to fix bug 581733
- # really, the entire shutdown sequence should be reconsidered and
- # made more robust.
- # See https://bugzilla.mozilla.org/show_bug.cgi?id=581733#c20
- # This will *NOT* work with all edge cases and it shouldn't be
- # expected that adding on more kills() for each edge case will ever
- # be able to fix a systematic issue by patching holes
- if fatal:
- self.runner.cleanup()
-
-
-class CLI(jsbridge.CLI):
- mozmill_class = MozMill
- module = "mozmill"
-
- def add_options(self, parser):
- jsbridge.CLI.add_options(self, parser)
- parser.add_option("-t", "--test", dest="test", action='append',
- default=[],
- help="Run test")
- parser.add_option("-l", "--logfile", dest="logfile",
- default=None,
- help="Log all events to file.")
- parser.add_option("--show-errors", dest="showerrors",
- default=False,
- action="store_true",
- help="Print logger errors to the console.")
- parser.add_option("--report", dest="report", default=False,
- help="Report the results. Requires url to results server. Use 'stdout' for stdout.")
- parser.add_option("--show-all", dest="showall", default=False,
- action="store_true",
- help="Show all test output.")
- parser.add_option("--timeout", dest="timeout", type="float",
- default=120.,
- help="seconds before harness timeout if no communication is taking place")
- parser.add_option("-m", "--manifest", dest='manifests',
- action='append',
- help='test manifest .ini file')
-
- def __init__(self, *args, **kwargs):
- jsbridge.CLI.__init__(self, *args, **kwargs)
- self.mozmill = self.mozmill_class(runner_class=mozrunner.FirefoxRunner,
- profile_class=mozprofile.FirefoxProfile,
- jsbridge_port=int(self.options.port),
- jsbridge_timeout=self.options.timeout,
- )
-
- self.tests = []
-
- # setup log formatting
- self.mozmill.add_global_listener(LoggerListener())
- log_options = {
- 'format': "%(levelname)s | %(message)s",
- 'level': logging.CRITICAL,
- }
- if self.options.showerrors:
- log_options['level'] = logging.ERROR
- if self.options.logfile:
- log_options['filename'] = self.options.logfile
- log_options['filemode'] = 'w'
- log_options['level'] = logging.DEBUG
- if self.options.test and self.options.showall:
- log_options['level'] = logging.DEBUG
- logging.basicConfig(**log_options)
-
- def profile_args(self):
- profargs = super(CLI, self).profile_args()
- profargs.setdefault('addons', []).append(extension_path)
- return profargs
-
- def run(self):
-
- # read tests from manifests
- if self.options.manifests:
- manifest_parser = manifestparser.TestManifest(manifests=self.options.manifests)
-
- self.tests.extend(manifest_parser.test_paths())
-
- # expand user directory for individual tests
- for test in self.options.test:
- test = os.path.expanduser(test)
- self.tests.append(test)
-
- # check existence for the tests
- missing = [test_ for test_ in self.tests if not os.path.exists(test)]
- if missing:
- raise IOError("Not a valid test file/directory: %s" % ', '.join(["'%s'" % test_ for test_ in missing]))
-
- # create a Mozrunner
- runner = self.create_runner()
-
- runner.cmdargs.extend(self.options.appArgs)
-
- # make sure the application starts in the foreground
- if '-foreground' not in runner.cmdargs:
- runner.cmdargs.append('-foreground')
-
- try:
- self.mozmill.start(runner=runner, profile=runner.profile)
- except:
- runner.cleanup()
- raise
-
- if self.tests:
-
- # run the tests
- disconnected = False
- try:
- self.mozmill.run_tests(self.tests)
- except JSBridgeDisconnectError:
- disconnected = True
- if not self.mozmill.userShutdownEnabled:
- self.mozmill.report_disconnect()
- print 'TEST-UNEXPECTED-FAIL | Disconnect Error: Application unexpectedly closed'
- runner.cleanup()
- except:
- runner.cleanup()
- raise
-
- # shutdown the test harness
- self.mozmill.stop(fatal=disconnected)
-
- # print statistics and send the JSON report
- self.mozmill.report(self.options.report)
-
- if self.mozmill.fails or disconnected:
- sys.exit(1)
- else:
- if self.options.shell:
- self.start_shell(runner)
- else:
- try:
- if not hasattr(runner, 'process_handler'):
- runner.start()
- runner.wait()
- except KeyboardInterrupt:
- runner.stop()
-
- if self.mozmill.runner is not None:
- self.mozmill.runner.cleanup()
-
-
-class RestartCLI(CLI):
- mozmill_class = MozMillRestart
-
-
-class ThunderbirdCLI(CLI):
- profile_class = mozprofile.ThunderbirdProfile
- runner_class = mozrunner.ThunderbirdRunner
-
-
-class ThunderbirdRestartCLI(RestartCLI):
- profile_class = mozprofile.ThunderbirdProfile
- runner_class = mozrunner.ThunderbirdRunner
-
-
-def enum(*sequential, **named):
- enums = dict(zip(sequential, range(len(sequential))), **named)
- return type('Enum', (), enums)
-
-
-def cli():
- CLI().run()
-
-
-def tbird_cli():
- ThunderbirdCLI().run()
-
-
-def restart_cli():
- RestartCLI().run()
-
-
-def tbird_restart_cli():
- ThunderbirdRestartCLI().run()
deleted file mode 100644
--- a/mail/test/resources/mozmill/mozmill/extension/bootstrap.js
+++ /dev/null
@@ -1,68 +0,0 @@
-/* -*- Mode: JavaScript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-var { ExtensionSupport } = ChromeUtils.import(
- "resource:///modules/ExtensionSupport.jsm"
-);
-var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-function install() {}
-
-function uninstall() {}
-
-function startup(data, reason) {
- let env = Cc["@mozilla.org/process/environment;1"].getService(
- Ci.nsIEnvironment
- );
- let protocolHandler = Services.io
- .getProtocolHandler("resource")
- .QueryInterface(Ci.nsIResProtocolHandler);
-
- let modulesPath = env.get("TESTING_MODULES_DIR");
- if (Services.appinfo.OS == "WINNT") {
- modulesPath = modulesPath.replace(/\//g, "\\");
- }
-
- let modulesDir = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
- modulesDir.initWithPath(modulesPath);
- protocolHandler.setSubstitution(
- "testing-common",
- Services.io.newFileURI(modulesDir)
- );
-
- loadDefaultPrefs();
-
- ExtensionSupport.registerWindowListener(data.id, {
- chromeURLs: ["chrome://messenger/content/messenger.xhtml"],
- onLoadWindow: setupUI,
- });
-}
-
-function loadDefaultPrefs() {
- let defaultBranch = Services.prefs.getDefaultBranch(null);
-
- // Debugging prefs
- defaultBranch.setBoolPref("browser.dom.window.dump.enabled", true);
- defaultBranch.setBoolPref("javascript.options.showInConsole", true);
-}
-
-function shutdown(data, reason) {
- ExtensionSupport.unregisterWindowListener(data.id);
-}
-
-function setupUI(domWindow) {
- console.log("=== Mozmill: Seen window " + domWindow.document.location.href);
- loadScript("chrome://mozmill/content/overlay.js", domWindow);
-}
-
-function loadScript(url, targetWindow) {
- Services.scriptloader.loadSubScript(url, targetWindow);
-}
-
-function logException(exc) {
- try {
- Services.console.logStringMessage(exc.toString() + "\n" + exc.stack);
- } catch (x) {}
-}
deleted file mode 100755
--- a/mail/test/resources/mozmill/mozmill/extension/chrome.manifest
+++ /dev/null
@@ -1,1 +0,0 @@
-content mozmill content/
deleted file mode 100755
--- a/mail/test/resources/mozmill/mozmill/extension/content/overlay.js
+++ /dev/null
@@ -1,49 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Corporation Code.
- *
- * The Initial Developer of the Original Code is
- * Adam Christian.
- * Portions created by the Initial Developer are Copyright (C) 2008
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Adam Christian <adam.christian@gmail.com>
- * Mikeal Rogers <mikeal.rogers@gmail.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-ChromeUtils.import("resource://testing-common/mozmill/init.jsm");
-
-var MozMill = {
- onLoad() {
- this.initialized = true;
- },
-};
-
-window.addEventListener("load", function(e) {
- MozMill.onLoad(e);
-});
deleted file mode 100644
--- a/mail/test/resources/mozmill/mozmill/extension/content/prefs.xhtml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0"?>
-<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
-
-<prefwindow id="mozmill-prefs"
- title="MozMill Preferences"
- xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml">
-
-<prefpane id="mozpref" label="MozMill Preferences">
- <preferences>
- <preference id="pref1" name="stockwatcher2.symbol" type="string"/>
- </preferences>
-
- <hbox align="center">
- <label control="symbol" value="All kinds of preferences go in here."/>
- </hbox>
-</prefpane>
-
-</prefwindow>
deleted file mode 100644
--- a/mail/test/resources/mozmill/mozmill/extension/manifest.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "manifest_version": 2,
- "name": "MozMill",
- "version": "1.6.2",
- "applications": {
- "gecko": {
- "id": "mozmill@mozilla.com"
- }
- },
- "legacy": {
- "type": "bootstrap",
- "options": {
- "page": "chrome://mozmill/content/prefs.xhtml"
- }
- }
-}
deleted file mode 100644
--- a/mail/test/resources/mozmill/setup.py
+++ /dev/null
@@ -1,80 +0,0 @@
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is Mozilla Corporation Code.
-#
-# The Initial Developer of the Original Code is
-# Mikeal Rogers.
-# Portions created by the Initial Developer are Copyright (C) 2008
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-# Mikeal Rogers <mikeal.rogers@gmail.com>
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 2 or later (the "GPL"), or
-# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-from setuptools import setup, find_packages
-
-desc = """UI Automation tool for Mozilla applications."""
-summ = """A tool for full UI automation of Mozilla applications."""
-
-PACKAGE_NAME = "mozmill_thunderbird"
-PACKAGE_VERSION = "1.7.1"
-
-setup(name=PACKAGE_NAME,
- version=PACKAGE_VERSION,
- description=desc,
- long_description=summ,
- author='Mozilla, Mikeal Rogers',
- author_email='mikeal.rogers@gmail.com',
- url='http://github.com/mozautomation/mozmill',
- license='http://www.apache.org/licenses/LICENSE-2.0',
- packages=find_packages(exclude=['test']),
- include_package_data=True,
- package_data={
- '': ['*.js', '*.css', '*.html', '*.txt', '*.xpi', '*.rdf', '*.xhtml', '*.jsm', '*.xml'],
- },
- zip_safe=False,
- entry_points="""
- [console_scripts]
- mozmill = mozmill:cli
- mozmill-thunderbird = mozmill:tbird_cli
- mozmill-restart = mozmill:restart_cli
- """,
- platforms=['Any'],
- install_requires=[
- 'jsbridge_thunderbird == 2.5.2',
- 'mozrunner >= 6.0',
- 'manifestparser >= 0.9'
- ],
- classifiers=[
- 'Development Status :: 4 - Beta',
- 'Environment :: Console',
- 'Intended Audience :: Developers',
- 'License :: OSI Approved :: Apache Software License',
- 'Operating System :: OS Independent',
- 'Topic :: Software Development :: Libraries :: Python Modules',
- ]
- )